Commit a3fc550a by Rocky Duan

make markdown & latex work for response / comments (not perfect)

parent a8b20cca
...@@ -4,4 +4,11 @@ class @ResponseCommentView extends Backbone.View ...@@ -4,4 +4,11 @@ class @ResponseCommentView extends Backbone.View
render: -> render: ->
@$el.html(@template(@model.toJSON())) @$el.html(@template(@model.toJSON()))
@$(".timeago").timeago() @$(".timeago").timeago()
@convertMath()
@ @
convertMath: ->
body = @$(".response-body")
body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.html()
body.children("p").each (index, elem) ->
$(elem).replaceWith($(elem).html())
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
...@@ -17,7 +17,7 @@ class @ThreadResponseView extends Backbone.View ...@@ -17,7 +17,7 @@ class @ThreadResponseView extends Backbone.View
convertMath: -> convertMath: ->
element = @$(".response-body") element = @$(".response-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html() element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.html()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element.attr("id")] MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
renderComments: -> renderComments: ->
@model.get("comments").each @renderComment @model.get("comments").each @renderComment
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
</script> </script>
<script type="text/template" id="response-comment-template"> <script type="text/template" id="response-comment-template">
<p>${'<%- body %>'}<span class="posted-details">posted <span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p> <p><span class="response-body">${'<%- body %>'}</span><span class="posted-details">–posted <span class="timeago" title="${'<%- created_at %>'}">sometime</span> by <a href="${'<%- user_url %>'}">${'<%- username %>'}</a></span></p>
</script> </script>
<script type="text/template" id="thread-list-item-template"> <script type="text/template" id="thread-list-item-template">
......
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