closed #104 - anchors now have rel="nofollow" and open in a new window

This commit is contained in:
Julian Lam
2013-07-22 12:44:50 -04:00
parent 104dbea3f2
commit f40bf46656
3 changed files with 26 additions and 9 deletions

View File

@@ -4,13 +4,9 @@ var RDB = require('./redis.js'),
threadTools = require('./threadTools.js'),
user = require('./user.js'),
async = require('async'),
marked = require('marked'),
utils = require('../public/src/utils');
marked.setOptions({
breaks: true
});
(function(PostTools) {
PostTools.isMain = function(pid, tid, callback) {
RDB.lrange('tid:' + tid + ':posts', 0, 0, function(err, pids) {
@@ -142,5 +138,22 @@ marked.setOptions({
});
}
PostTools.markdownToHTML = function(md) {
var marked = require('marked'),
cheerio = require('cheerio');
marked.setOptions({
breaks: true
});
if (md.length > 0) {
var parsedContentDOM = cheerio.load(marked(md));
parsedContentDOM('a').attr('rel', 'nofollow').attr('target', '_blank');
html = parsedContentDOM.html();
} else html = '<p></p>';
return html;
}
}(exports));