11import { resolvePath } from '../../common/npmLib'
22
33export default async function math ( ) {
4- if ( document . getElementsByTagName ( 'math' ) . length > 0 || document . querySelector ( 'article > div.entry-content' ) ?. textContent . match ( / (?: \$ | \\ \( | \\ \[ | \\ b e g i n \{ .* ?} ) / ) ) {
5- const mathjaxConfig = {
6- tex : {
7- inlineMath : [ [ '$' , '$' ] , [ '\\(' , '\\)' ] ]
8- } ,
9- startup : {
10- typeset : false , // Perform initial typeset?
11- } ,
12- chtml : {
13- fontURL : resolvePath ( 'es5/output/chtml/fonts/woff-v2' , 'mathjax' ) ,
14- mathmlSpacing : true // true for MathML spacing rules, false for TeX rules
15- }
16- }
4+ if ( _iro . theme_mathjax &&
5+ (
6+ document . getElementsByTagName ( 'math' ) . length > 0 ||
7+ document . querySelector ( 'article > div.entry-content' ) ?. textContent . match ( / (?: \$ | \\ \( | \\ \[ | \\ b e g i n \{ .* ?} ) / )
8+ )
9+ ) {
1710 if ( ! ( 'MathJax' in window ) ) {
11+ const mathjaxConfig = {
12+ tex : {
13+ inlineMath : [ [ '$' , '$' ] , [ '\\(' , '\\)' ] ]
14+ } ,
15+ startup : {
16+ typeset : false , // Perform initial typeset?
17+ } ,
18+ chtml : {
19+ fontURL : resolvePath ( 'es5/output/chtml/fonts/woff-v2' , 'mathjax' ) ,
20+ mathmlSpacing : true // true for MathML spacing rules, false for TeX rules
21+ }
22+ }
1823 //@ts -ignore
1924 window . MathJax = mathjaxConfig
2025 }
2126 //@ts -ignore
22- await import ( 'mathjax/es5/tex-mml-chtml' ) //@ts -ignore
27+ await import ( 'mathjax/es5/tex-mml-chtml' )
28+ //@ts -ignore
2329 window . MathJax . typesetPromise ( )
2430 }
2531}
0 commit comments