2021-09-15 10:06:32 -04:00
|
|
|
/* global MathJax */
|
|
|
|
|
|
|
|
import { mathJaxLoaded } from './util'
|
2022-12-08 07:27:59 -05:00
|
|
|
import getMeta from '../../utils/meta'
|
2021-09-15 10:06:32 -04:00
|
|
|
|
|
|
|
let configured = false
|
|
|
|
|
|
|
|
export function configureMathJax() {
|
|
|
|
if (configured) return
|
2023-01-23 06:41:24 -05:00
|
|
|
if (getMeta('ol-mathJax3Path')) return
|
2021-09-15 10:06:32 -04:00
|
|
|
if (!mathJaxLoaded()) return
|
|
|
|
|
2022-12-08 07:27:59 -05:00
|
|
|
const inlineMath = [['\\(', '\\)']]
|
|
|
|
|
|
|
|
if (!getMeta('ol-no-single-dollar')) {
|
|
|
|
inlineMath.push(['$', '$'])
|
|
|
|
}
|
|
|
|
|
2021-09-15 10:06:32 -04:00
|
|
|
MathJax.Hub.Config({
|
|
|
|
messageStyle: 'none',
|
|
|
|
imageFont: null,
|
|
|
|
// Fast preview, introduced in 2.5, is unhelpful due to extra codemirror refresh
|
|
|
|
// and disabling it avoids issues with math processing errors
|
|
|
|
// github.com/overleaf/write_latex/pull/1375
|
|
|
|
'fast-preview': { disabled: true },
|
|
|
|
'HTML-CSS': {
|
|
|
|
availableFonts: ['TeX'],
|
|
|
|
// MathJax's automatic font scaling does not work well when we render math
|
|
|
|
// that isn't yet on the page, so we disable it and set a global font
|
|
|
|
// scale factor
|
|
|
|
scale: 110,
|
|
|
|
matchFontHeight: false,
|
|
|
|
},
|
|
|
|
TeX: {
|
|
|
|
equationNumbers: { autoNumber: 'AMS' },
|
|
|
|
useLabelIDs: false,
|
|
|
|
},
|
|
|
|
skipStartupTypeset: true,
|
|
|
|
tex2jax: {
|
|
|
|
processEscapes: true,
|
2022-12-08 07:27:59 -05:00
|
|
|
inlineMath,
|
2021-09-15 10:06:32 -04:00
|
|
|
displayMath: [
|
|
|
|
['$$', '$$'],
|
|
|
|
['\\[', '\\]'],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
})
|
|
|
|
configured = true
|
|
|
|
}
|