mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #10785 from overleaf/ae-mathjax-inline-single-dollar
Move MathJax inlineMath configuration from element to page GitOrigin-RevId: f17af484a0df517d6006ee1d42bde01d9c1fed08
This commit is contained in:
parent
f9aaa4d5de
commit
d420c247e1
3 changed files with 8 additions and 40 deletions
|
@ -1,4 +1,3 @@
|
|||
import _ from 'lodash'
|
||||
/* global MathJax */
|
||||
|
||||
import App from '../base'
|
||||
|
@ -8,23 +7,6 @@ export default App.directive('mathjax', function ($compile, $parse) {
|
|||
link(scope, element, attrs) {
|
||||
if (!(MathJax && MathJax.Hub)) return
|
||||
|
||||
if (attrs.delimiter !== 'no-single-dollar') {
|
||||
const inlineMathConfig =
|
||||
MathJax.Hub.config && 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, element.get(0)])
|
||||
}, 0)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* global MathJax */
|
||||
|
||||
import { mathJaxLoaded } from './util'
|
||||
import getMeta from '../../utils/meta'
|
||||
|
||||
let configured = false
|
||||
|
||||
|
@ -8,6 +9,12 @@ export function configureMathJax() {
|
|||
if (configured) return
|
||||
if (!mathJaxLoaded()) return
|
||||
|
||||
const inlineMath = [['\\(', '\\)']]
|
||||
|
||||
if (!getMeta('ol-no-single-dollar')) {
|
||||
inlineMath.push(['$', '$'])
|
||||
}
|
||||
|
||||
MathJax.Hub.Config({
|
||||
messageStyle: 'none',
|
||||
imageFont: null,
|
||||
|
@ -30,8 +37,7 @@ export function configureMathJax() {
|
|||
skipStartupTypeset: true,
|
||||
tex2jax: {
|
||||
processEscapes: true,
|
||||
// Dollar delimiters are added by the mathjax directive
|
||||
inlineMath: [['\\(', '\\)']],
|
||||
inlineMath,
|
||||
displayMath: [
|
||||
['$$', '$$'],
|
||||
['\\[', '\\]'],
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* global MathJax */
|
||||
import _ from 'lodash'
|
||||
import { configureMathJax } from './configure'
|
||||
import { mathJaxLoaded } from './util'
|
||||
|
||||
|
@ -7,25 +6,6 @@ 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)
|
||||
|
|
Loading…
Reference in a new issue