configure.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* global MathJax */
  2. import { mathJaxLoaded } from './util'
  3. import getMeta from '../../utils/meta'
  4. let configured = false
  5. export function configureMathJax() {
  6. if (configured) return
  7. if (getMeta('ol-mathJax3Path')) return
  8. if (!mathJaxLoaded()) return
  9. const inlineMath = [['\\(', '\\)']]
  10. if (!getMeta('ol-no-single-dollar')) {
  11. inlineMath.push(['$', '$'])
  12. }
  13. MathJax.Hub.Config({
  14. messageStyle: 'none',
  15. imageFont: null,
  16. // Fast preview, introduced in 2.5, is unhelpful due to extra codemirror refresh
  17. // and disabling it avoids issues with math processing errors
  18. // github.com/overleaf/write_latex/pull/1375
  19. 'fast-preview': { disabled: true },
  20. 'HTML-CSS': {
  21. availableFonts: ['TeX'],
  22. // MathJax's automatic font scaling does not work well when we render math
  23. // that isn't yet on the page, so we disable it and set a global font
  24. // scale factor
  25. scale: 110,
  26. matchFontHeight: false,
  27. },
  28. TeX: {
  29. equationNumbers: { autoNumber: 'AMS' },
  30. useLabelIDs: false,
  31. },
  32. skipStartupTypeset: true,
  33. tex2jax: {
  34. processEscapes: true,
  35. inlineMath,
  36. displayMath: [
  37. ['$$', '$$'],
  38. ['\\[', '\\]'],
  39. ],
  40. },
  41. })
  42. configured = true
  43. }