Commit dd9044d4 by Rocky Duan

should process marked users AFTER markdown

parent 790d4cab
...@@ -367,11 +367,16 @@ if Backbone? ...@@ -367,11 +367,16 @@ if Backbone?
initTitle: -> initTitle: ->
$contentTitle = @$(".thread-title") $contentTitle = @$(".thread-title")
if @model.get('marked_title')
$contentTitle.html _.escape @model.get('marked_title')
if $contentTitle.length if $contentTitle.length
$contentTitle.html DiscussionUtil.unescapeHighlightTag DiscussionUtil.stripLatexHighlight $contentTitle.html() $contentTitle.html DiscussionUtil.unescapeHighlightTag DiscussionUtil.stripLatexHighlight $contentTitle.html()
initBody: -> initBody: ->
$contentBody = @$(".content-body") $contentBody = @$(".content-body")
if @model.get('marked_body')
$contentBody.html _.escape @model.get('marked_body')
$contentBody.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight $contentBody.html() $contentBody.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight $contentBody.html()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, $contentBody.attr("id")] MathJax.Hub.Queue ["Typeset", MathJax.Hub, $contentBody.attr("id")]
...@@ -387,16 +392,10 @@ if Backbone? ...@@ -387,16 +392,10 @@ if Backbone?
@model.view = @ @model.view = @
@model.bind('change', @renderPartial, @) @model.bind('change', @renderPartial, @)
initAtUsers: ->
#@model.get('title').replace AT_NOTIFICATION_REGEX
#console.log @model.get('at_position_list')
S_LT = "\\&lt\\;" S_LT = "\\&lt\\;"
S_GT = "\\&gt\\;" S_GT = "\\&gt\\;"
S_QUOTE = "\\&\\#x27\\;" S_QUOTE = "\\'"
S_BKSLASH = "\\&\\#x2F\\;" S_BKSLASH = "\\/"
RE_MENTIONED_USER = /// RE_MENTIONED_USER = ///
#{S_LT} span \s* class= #{S_QUOTE} mentioned_user #{S_QUOTE} #{S_LT} span \s* class= #{S_QUOTE} mentioned_user #{S_QUOTE}
\s* user_id= #{S_QUOTE} (\w+) #{S_QUOTE} #{S_GT} \s* user_id= #{S_QUOTE} (\w+) #{S_QUOTE} #{S_GT}
...@@ -405,14 +404,12 @@ if Backbone? ...@@ -405,14 +404,12 @@ if Backbone?
///g ///g
initMarkedContent: -> initMarkedContent: ->
console.log "initializing" unescape = (text) ->
_escape = (text) -> text.replace RE_MENTIONED_USER, ($0, $1, $2) ->
_.escape(text).replace RE_MENTIONED_USER, ($0, $1, $2) ->
"<span class='mentioned_user' user_id='#{$1}'>#{$2}</span>" "<span class='mentioned_user' user_id='#{$1}'>#{$2}</span>"
if @model.get('marked_title') if @$(".thread-title").length
@$(".thread-title").html(_escape(@model.get('marked_title'))) @$(".thread-title").html unescape(@$(".thread-title").html())
if @model.get('marked_body') @$(".content-body").html unescape(@$(".content-body").html())
@$(".content-body").html(_escape(@model.get('marked_body')))
@$(".mentioned_user").each (index, elem) => @$(".mentioned_user").each (index, elem) =>
userId = $(elem).attr("user_id") userId = $(elem).attr("user_id")
href = DiscussionUtil.urlFor('user_profile', userId) href = DiscussionUtil.urlFor('user_profile', userId)
...@@ -425,7 +422,6 @@ if Backbone? ...@@ -425,7 +422,6 @@ if Backbone?
@initTitle() @initTitle()
@initBody() @initBody()
@initMarkedContent() @initMarkedContent()
@initAtUsers()
@initCommentViews() @initCommentViews()
reconstruct: -> reconstruct: ->
...@@ -437,7 +433,6 @@ if Backbone? ...@@ -437,7 +433,6 @@ if Backbone?
@initTitle() @initTitle()
@initBody() @initBody()
@initMarkedContent() @initMarkedContent()
@initAtUsers()
@delegateEvents() @delegateEvents()
class @Thread extends @Content class @Thread extends @Content
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment