overleaf/services/web/public/coffee/directives/mathjax.coffee
Alasdair Smith db518e16aa Don't set config unless needed in directive
Updates mathjax directive to only set config if it is needed. The main
config is now set in base.coffee so isn't needed
2018-07-23 15:32:17 +01:00

21 lines
No EOL
550 B
CoffeeScript

define [
"base"
], (App) ->
App.directive "mathjax", () ->
return {
link: (scope, element, attrs) ->
if attrs.delimiter != 'no-single-dollar'
inlineMathConfig = MathJax?.Hub?.config?.tex2jax.inlineMath
alreadyConfigured = _.find inlineMathConfig, (c) ->
c[0] == '$' and c[1] == '$'
if !alreadyConfigured?
MathJax?.Hub?.Config(
tex2jax:
inlineMath: inlineMathConfig.concat([['$', '$']])
)
setTimeout () ->
MathJax?.Hub?.Queue(["Typeset", MathJax?.Hub, element.get(0)])
, 0
}