2023-08-29 06:14:04 -04:00
|
|
|
const MATHJAX_STUB = `
|
2023-11-07 06:52:06 -05:00
|
|
|
window.MathJax = {
|
2023-08-29 06:14:04 -04:00
|
|
|
startup: {
|
|
|
|
promise: Promise.resolve()
|
2023-11-07 06:52:06 -05:00
|
|
|
},
|
2023-10-25 07:11:14 -04:00
|
|
|
svgStylesheet: () => document.createElement("STYLE"),
|
|
|
|
typesetPromise: (elements) => {
|
|
|
|
for (const element of elements) {
|
|
|
|
// This will keep math delimeters around the text
|
|
|
|
element.classList.add('MathJax')
|
|
|
|
}
|
|
|
|
return Promise.resolve()
|
|
|
|
},
|
|
|
|
tex2svgPromise: (content) => {
|
|
|
|
const text = document.createElement('SPAN')
|
|
|
|
text.classList.add('MathJax')
|
|
|
|
text.innerText = content
|
|
|
|
return Promise.resolve(text)
|
|
|
|
},
|
|
|
|
getMetricsFor: () => ({}),
|
|
|
|
texReset: () => {},
|
2023-08-29 06:14:04 -04:00
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
export const interceptMathJax = () => {
|
2023-11-07 06:52:06 -05:00
|
|
|
// NOTE: this is just a URL to be intercepted with the stub, not the real (versioned) MathJax URL
|
2024-02-08 04:34:07 -05:00
|
|
|
const url = '/js/libs/mathjax/es5/tex-svg-full.js'
|
2023-08-29 06:14:04 -04:00
|
|
|
cy.window().then(win => {
|
2024-02-08 04:34:07 -05:00
|
|
|
win.metaAttributesCache.set('ol-mathJaxPath', url)
|
2023-08-29 06:14:04 -04:00
|
|
|
})
|
2023-11-07 06:52:06 -05:00
|
|
|
cy.intercept('GET', url, MATHJAX_STUB).as('mathjax-load-request')
|
2023-08-29 06:14:04 -04:00
|
|
|
}
|