Commit 4f326a8c by Waqas Khalid

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

Discussion forum should be independent of mathjax 
parents 20c9a8af 11159ba7
...@@ -10,6 +10,7 @@ if Backbone? ...@@ -10,6 +10,7 @@ if Backbone?
@$el.html(Mustache.render(@template, params)) @$el.html(Mustache.render(@template, params))
@$("span.timeago").timeago() @$("span.timeago").timeago()
element = @$(".post-body") element = @$(".post-body")
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]] MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
@ @
......
...@@ -32,6 +32,7 @@ if Backbone? ...@@ -32,6 +32,7 @@ if Backbone?
convertMath: -> convertMath: ->
element = @$(".post-body") element = @$(".post-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.text() element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.text()
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]] MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
edit: (event) -> edit: (event) ->
......
...@@ -33,6 +33,7 @@ if Backbone? ...@@ -33,6 +33,7 @@ if Backbone?
convertMath: -> convertMath: ->
body = @$el.find(".response-body") body = @$el.find(".response-body")
body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.text() body.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight body.text()
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]] MathJax.Hub.Queue ["Typeset", MathJax.Hub, body[0]]
_delete: (event) => _delete: (event) =>
......
...@@ -27,6 +27,7 @@ if Backbone? ...@@ -27,6 +27,7 @@ if Backbone?
convertMath: -> convertMath: ->
element = @$(".response-body") element = @$(".response-body")
element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.text() element.html DiscussionUtil.postMathJaxProcessor DiscussionUtil.markdownWithHighlight element.text()
if MathJax?
MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]] MathJax.Hub.Queue ["Typeset", MathJax.Hub, element[0]]
edit: (event) -> edit: (event) ->
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
tex2jax: {inlineMath: [ ['$','$'], ["\\(","\\)"]], tex2jax: {inlineMath: [ ['$','$'], ["\\(","\\)"]],
displayMath: [ ['$$','$$'], ["\\[","\\]"]]} displayMath: [ ['$$','$$'], ["\\[","\\]"]]}
}); });
HUB = MathJax.Hub
</script> </script>
%else: %else:
<script type="text/x-mathjax-config"> <script type="text/x-mathjax-config">
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
] ]
} }
}); });
HUB = MathJax.Hub
</script> </script>
%endif %endif
......
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
$ -> $ ->
if not MathJax?
return
HUB = MathJax.Hub
class MathJaxProcessor class MathJaxProcessor
MATHSPLIT = /// ( MATHSPLIT = /// (
...@@ -116,6 +111,7 @@ $ -> ...@@ -116,6 +111,7 @@ $ ->
Markdown.getMathCompatibleConverter = (postProcessor) -> Markdown.getMathCompatibleConverter = (postProcessor) ->
postProcessor ||= ((text) -> text) postProcessor ||= ((text) -> text)
converter = Markdown.getSanitizingConverter() converter = Markdown.getSanitizingConverter()
if MathJax?
processor = new MathJaxProcessor() processor = new MathJaxProcessor()
converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor) converter.hooks.chain "preConversion", MathJaxProcessor.removeMathWrapper(processor)
converter.hooks.chain "postConversion", (text) -> converter.hooks.chain "postConversion", (text) ->
......
...@@ -57,7 +57,7 @@ class @MathJaxDelayRenderer ...@@ -57,7 +57,7 @@ class @MathJaxDelayRenderer
@$buffer.html(text) @$buffer.html(text)
curTime = getTime() curTime = getTime()
@elapsedTime = curTime - prevTime @elapsedTime = curTime - prevTime
if MathJax if MathJax?
prevTime = getTime() prevTime = getTime()
@mathjaxRunning = true @mathjaxRunning = true
MathJax.Hub.Queue ["Typeset", MathJax.Hub, @$buffer.attr("id")], => MathJax.Hub.Queue ["Typeset", MathJax.Hub, @$buffer.attr("id")], =>
......
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