From 99ba792e6dbb67024d81c920dd986c968eb3f399 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 22 Jul 2013 12:58:10 -0400 Subject: [PATCH] changing all calls to marked to instead go through PostTools.markdownToHTML --- src/postTools.js | 2 +- src/posts.js | 9 ++------- src/routes/user.js | 3 ++- src/topics.js | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/postTools.js b/src/postTools.js index 4797e3dc65..c8a982bbc6 100644 --- a/src/postTools.js +++ b/src/postTools.js @@ -63,7 +63,7 @@ var RDB = require('./redis.js'), io.sockets.in('topic_' + tid).emit('event:post_edited', { pid: pid, title: title, - content: marked(content || '') + content: PostTools.markdownToHTML(content) }); }); }); diff --git a/src/posts.js b/src/posts.js index 5fd45b4f67..09cc5938f8 100644 --- a/src/posts.js +++ b/src/posts.js @@ -1,7 +1,6 @@ var RDB = require('./redis.js'), utils = require('./../public/src/utils.js'), schema = require('./schema.js'), - marked = require('marked'), user = require('./user.js'), topics = require('./topics.js'), favourites = require('./favourites.js'), @@ -10,10 +9,6 @@ var RDB = require('./redis.js'), feed = require('./feed.js'), async = require('async'); -marked.setOptions({ - breaks: true -}); - (function(Posts) { Posts.minimumPostLength = 8; @@ -43,7 +38,7 @@ marked.setOptions({ post.user_rep = userData.reputation || 0; post.user_postcount = userData.postcount || 0; post.picture = userData.picture || require('gravatar').url('', {}, https=global.nconf.get('https')); - post.signature = marked(userData.signature || ''); + post.signature = postTools.markdownToHTML(userData.signature); if(post.editor !== '') { user.getUserFields(post.editor, ['username', 'userslug'], function(editorData) { @@ -243,7 +238,7 @@ marked.setOptions({ timeout: 2000 }); - postData.content = marked(postData.content); + postData.content = postTools.markdownToHTML(postData.content); postData.post_rep = 0; postData.relativeTime = utils.relativeTime(postData.timestamp) postData.fav_star_class = 'icon-star-empty'; diff --git a/src/routes/user.js b/src/routes/user.js index f1d60fc7ab..6afd2fda41 100644 --- a/src/routes/user.js +++ b/src/routes/user.js @@ -1,5 +1,6 @@ var user = require('./../user.js'), posts = require('./../posts.js'), + postTools = require('../postTools'), fs = require('fs'), utils = require('./../../public/src/utils.js'), path = require('path'), @@ -229,7 +230,7 @@ var user = require('./../user.js'), userData.posts = posts.filter(function(p) {return p.deleted !== "1";}); userData.isFollowing = isFollowing; - userData.signature = marked(userData.signature || ''); + userData.signature = postTools.markdownToHTML(userData.signature); res.json(userData); }); }); diff --git a/src/topics.js b/src/topics.js index e0270a1d04..f660325776 100644 --- a/src/topics.js +++ b/src/topics.js @@ -293,7 +293,7 @@ marked.setOptions({ timestamp = postData.timestamp; if(postData.content) - stripped = utils.strip_tags(marked(postData.content)); + stripped = utils.strip_tags(postTools.markdownToHTML(postData.content)); callback(null, { "text": stripped,