mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
40a1c302f9
[web] de-ng learn wiki page GitOrigin-RevId: defb1c1c90fe17e843f36253e81c2455b7dddfb1
34 lines
821 B
JavaScript
34 lines
821 B
JavaScript
/* global MathJax */
|
|
import _ from 'lodash'
|
|
import { configureMathJax } from './configure'
|
|
import { mathJaxLoaded } from './util'
|
|
|
|
function render(el) {
|
|
if (!mathJaxLoaded()) return
|
|
configureMathJax()
|
|
|
|
if (!el.hasAttribute('data-ol-no-single-dollar')) {
|
|
const inlineMathConfig =
|
|
MathJax.Hub.config &&
|
|
MathJax.Hub.config.tex2jax &&
|
|
MathJax.Hub.config.tex2jax.inlineMath
|
|
const alreadyConfigured = _.find(
|
|
inlineMathConfig,
|
|
c => c[0] === '$' && c[1] === '$'
|
|
)
|
|
|
|
if (!alreadyConfigured) {
|
|
MathJax.Hub.Config({
|
|
tex2jax: {
|
|
inlineMath: inlineMathConfig.concat([['$', '$']]),
|
|
},
|
|
})
|
|
}
|
|
}
|
|
|
|
setTimeout(() => {
|
|
MathJax.Hub.Queue(['Typeset', MathJax.Hub, el])
|
|
}, 0)
|
|
}
|
|
|
|
document.querySelectorAll('[data-ol-mathjax]').forEach(render)
|