Support MathJax 4 (#985)

This commit is contained in:
Mimi 2026-08-05 10:28:55 +08:00 committed by GitHub
parent 091af0fd4f
commit c0232764b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 5 deletions

View File

@ -27,9 +27,9 @@ prism_line_numbers:
integrity: sha256-9cmf7tcLdXpKsPi/2AWE93PbZpTp4M4tqzFk+lWomjU= integrity: sha256-9cmf7tcLdXpKsPi/2AWE93PbZpTp4M4tqzFk+lWomjU=
mathjax: mathjax:
name: mathjax name: mathjax
version: 3.2.2 version: 4.1.3
file: es5/tex-mml-chtml.js file: tex-mml-chtml.js
integrity: sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI= integrity: sha256-ihPtDDm7pTmSF9ViEsItlvsrBTsNkz0MOXMchzOwCQw=
katex: katex:
name: katex name: katex
version: 0.16.9 version: 0.16.9

View File

@ -1,4 +1,5 @@
{{ next_data('mathjax', theme.math.mathjax, { {{ next_data('mathjax', theme.math.mathjax, {
js: theme.vendors.mathjax js: theme.vendors.mathjax,
font_path: theme.vendors.mathjax_font_path
}) }} }) }}
{{ next_js('third-party/math/mathjax.js') }} {{ next_js('third-party/math/mathjax.js') }}

View File

@ -57,5 +57,10 @@ module.exports = hexo => {
// Omit integrity for local assets. // Omit integrity for local assets.
integrity: plugins === 'local' ? undefined : value.integrity integrity: plugins === 'local' ? undefined : value.integrity
}; };
if (key === 'mathjax') {
vendors.mathjax_font_path = plugins === 'local'
? url_for.call(hexo, 'lib/@mathjax/mathjax-newcm-font')
: undefined;
}
} }
}; };

View File

@ -20,7 +20,10 @@ document.addEventListener('page:loaded', () => {
}); });
}, '', false] }, '', false]
} }
} },
output: CONFIG.mathjax.font_path ? {
fontPath: CONFIG.mathjax.font_path
} : {}
}; };
NexT.utils.getScript(CONFIG.mathjax.js, { NexT.utils.getScript(CONFIG.mathjax.js, {
attributes: { attributes: {