Merge pull request #6832 from edx/waqas/tnl1149-discussion-mathjax-solution

Discussion forum should be independent of mathjax
This commit is contained in:
Waqas Khalid
2015-02-11 20:27:45 +05:00
7 changed files with 16 additions and 14 deletions

View File

@@ -10,7 +10,8 @@ if Backbone?
@$el.html(Mustache.render(@template, params))
@$("span.timeago").timeago()
element = @$(".post-body")
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
@
convertMath: ->

View File

@@ -32,7 +32,8 @@ if Backbone?
convertMath: ->
element = @$(".post-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.text()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
edit: (event) ->
@trigger "thread:edit", event

View File

@@ -33,7 +33,8 @@ if Backbone?
convertMath: ->
body = @$el.find(".response-body")
body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.text()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
_delete: (event) =>
@trigger "comment:_delete", event

View File

@@ -27,7 +27,8 @@ if Backbone?
convertMath: ->
element = @$(".response-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.text()
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
edit: (event) ->
@trigger "response:edit", event

View File

@@ -12,6 +12,7 @@
tex2jax: {inlineMath: [ ['$','$'], ["\\(","\\)"]],
displayMath: [ ['$$','$$'], ["\\[","\\]"]]}
});
HUB = MathJax.Hub
</script>
%else:
<script type="text/x-mathjax-config">
@@ -27,6 +28,7 @@
]
}
});
HUB = MathJax.Hub
</script>
%endif

View File

@@ -2,11 +2,6 @@
$ ->
if not MathJax?
return
HUB = MathJax.Hub
class MathJaxProcessor
MATHSPLIT = /// (
@@ -116,10 +111,11 @@ $ ->
Markdown.getMathCompatibleConverter = (postProcessor) ->
postProcessor ||= ((text) -> text)
converter = Markdown.getSanitizingConverter()
processor = new MathJaxProcessor()
converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor)
converter.hooks.chain "postConversion", (text) ->
postProcessor(MathJaxProcessor.replaceMathWrapper(processor)(text))
if MathJax?
processor = new MathJaxProcessor()
converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor)
converter.hooks.chain "postConversion", (text) ->
postProcessor(MathJaxProcessor.replaceMathWrapper(processor)(text))
converter
Markdown.makeWmdEditor = (elem, appended_id, imageUploadUrl, postProcessor) ->

View File

@@ -57,7 +57,7 @@ class @MathJaxDelayRenderer
@$buffer.html(text)
curTime = getTime()
@elapsedTime = curTime - prevTime
if MathJax
if MathJax?
prevTime = getTime()
@mathjaxRunning = true
MathJax.Hub.Queue ["Typeset", MathJax.Hub, @$buffer.attr("id")], =>