(rerun = false)
| 1 | const handleMathJax = (rerun = false) => { |
| 2 | if (typeof window === 'undefined') { |
| 3 | return; |
| 4 | } |
| 5 | |
| 6 | const mathjaxScript = 'https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'; |
| 7 | if (!window.MathJax) { |
| 8 | window.MathJax = { |
| 9 | tex: { |
| 10 | inlineMath: [['\\(', '\\)']], |
| 11 | }, |
| 12 | }; |
| 13 | } |
| 14 | |
| 15 | let mathjaxScriptTag = document.querySelector(`script[src="${mathjaxScript}"]`); |
| 16 | if (!mathjaxScriptTag) { |
| 17 | let script = document.createElement('script'); |
| 18 | script.type = 'text/javascript'; |
| 19 | script.src = mathjaxScript; |
| 20 | script.onload = function () { |
| 21 | window.MathJax && 'mathml2chtml' in window.MathJax && window.MathJax.mathml2chtml(); |
| 22 | }; |
| 23 | document.head.appendChild(script); |
| 24 | } else if (rerun) { |
| 25 | window.MathJax && 'mathml2chtml' in window.MathJax && window.MathJax.mathml2chtml(); |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | export default handleMathJax; |
| 30 |
nothing calls this directly
no outgoing calls
no test coverage detected