overleaf/services/web/public/coffee/directives/mathjax.coffee

21 lines
550 B
CoffeeScript
Raw Normal View History

2014-07-17 08:23:43 -04:00
define [
"base"
2018-07-13 16:02:52 -04:00
], (App) ->
2014-07-17 08:23:43 -04:00
App.directive "mathjax", () ->
return {
link: (scope, element, attrs) ->
2018-07-13 16:02:52 -04:00
if attrs.delimiter != 'no-single-dollar'
inlineMathConfig = MathJax?.Hub?.config?.tex2jax.inlineMath
alreadyConfigured = _.find inlineMathConfig, (c) ->
c[0] == '$' and c[1] == '$'
2018-07-13 16:02:52 -04:00
if !alreadyConfigured?
MathJax?.Hub?.Config(
tex2jax:
inlineMath: inlineMathConfig.concat([['$', '$']])
)
2018-07-13 16:02:52 -04:00
2014-07-17 08:23:43 -04:00
setTimeout () ->
2015-02-23 12:46:17 -05:00
MathJax?.Hub?.Queue(["Typeset", MathJax?.Hub, element.get(0)])
2014-07-17 08:23:43 -04:00
, 0
}