Commit bafe07da authored by RawKStar77's avatar RawKStar77

Breakout loading MathJax into separate function

parent 96e80ff9
...@@ -252,6 +252,22 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc ...@@ -252,6 +252,22 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc
$timeout -> inputEl.focus() $timeout -> inputEl.focus()
MathJaxFallback = false MathJaxFallback = false
loadMathJax = ->
try
if !MathJax?
$.ajax {
url:"//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
dataType: 'script'
cache: true
complete: ->
# MathJax configuration overides.
MathJax.Hub.Config({
showMathMenu: false
})
}
catch error
console.log error
renderMath = (textToCheck) -> renderMath = (textToCheck) ->
# Parses text for math as denoted by '$$' # Parses text for math as denoted by '$$'
i = 0 i = 0
...@@ -267,26 +283,13 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc ...@@ -267,26 +283,13 @@ markdown = ['$filter', '$sanitize', '$sce', '$timeout', ($filter, $sanitize, $sc
if startMath != null and endMath != null if startMath != null and endMath != null
try try
math = katex.renderToString(textToCheck.substring(startMath, endMath)) math = katex.renderToString(textToCheck.substring(startMath, endMath))
catch error catch
# KaTex does not have full math support. In the case that we come across math we # KaTex does not have full math support. In the case that we come across math we
# can't render, we load MathJax and render the Math with MathJax. # can't render, we load MathJax and render the Math with MathJax.
math = textToCheck.substring(startMath, endMath) math = textToCheck.substring(startMath, endMath)
scope.MathJaxFallback = true scope.MathJaxFallback = true
try loadMathJax()
if !MathJax? return textToCheck
$.ajax {
url:"//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
dataType: 'script'
cache: true
complete: ->
# MathJax configuration overides.
MathJax.Hub.Config({
showMathMenu: false
})
}
return textToCheck
catch error
console.log error
textToCheck = ( textToCheck = (
textToCheck.substring(0, (startMath - 2)) + math + textToCheck.substring(0, (startMath - 2)) + math +
textToCheck.substring((endMath + 2)) textToCheck.substring((endMath + 2))
......
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