mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
closed #104 - anchors now have rel="nofollow" and open in a new window
This commit is contained in:
@@ -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));
|
||||
Reference in New Issue
Block a user