mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
refactored postTools.toHTML to fire post.parse hook, and removed auto-markdowning
closed #214
This commit is contained in:
@@ -35,7 +35,8 @@
|
|||||||
"request": "~2.25.0",
|
"request": "~2.25.0",
|
||||||
"reds": "~0.2.4",
|
"reds": "~0.2.4",
|
||||||
"winston": "~0.7.2",
|
"winston": "~0.7.2",
|
||||||
"nodebb-plugin-mentions": "~0.1.0"
|
"nodebb-plugin-mentions": "~0.1.0",
|
||||||
|
"nodebb-plugin-markdown": "~0.1.0"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/designcreateplay/NodeBB/issues"
|
"url": "https://github.com/designcreateplay/NodeBB/issues"
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ var RDB = require('./redis.js'),
|
|||||||
|
|
||||||
PostTools.privileges(pid, uid, function(privileges) {
|
PostTools.privileges(pid, uid, function(privileges) {
|
||||||
if (privileges.editable) {
|
if (privileges.editable) {
|
||||||
plugins.fireHook('filter:save_post_content', content, function(parsedContent) {
|
plugins.fireHook('filter:post.save', content, function(parsedContent) {
|
||||||
content = parsedContent;
|
content = parsedContent;
|
||||||
success();
|
success();
|
||||||
});
|
});
|
||||||
@@ -170,15 +170,11 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
|
|
||||||
PostTools.toHTML = function(raw, callback) {
|
PostTools.toHTML = function(raw, callback) {
|
||||||
var marked = require('marked'),
|
plugins.fireHook('filter:post.parse', raw, function(parsed) {
|
||||||
cheerio = require('cheerio');
|
var cheerio = require('cheerio');
|
||||||
|
|
||||||
marked.setOptions({
|
if (parsed && parsed.length > 0) {
|
||||||
breaks: true
|
var parsedContentDOM = cheerio.load(parsed);
|
||||||
});
|
|
||||||
|
|
||||||
if (raw && raw.length > 0) {
|
|
||||||
var parsedContentDOM = cheerio.load(marked(raw));
|
|
||||||
var domain = nconf.get('url');
|
var domain = nconf.get('url');
|
||||||
|
|
||||||
parsedContentDOM('a').each(function() {
|
parsedContentDOM('a').each(function() {
|
||||||
@@ -190,11 +186,11 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
callback(null, parsedContentDOM.html());
|
callback(null, parsedContentDOM.html());
|
||||||
} else {
|
} else {
|
||||||
callback(null, '<p></p>');
|
callback(null, '<p></p>');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user