mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-09-13 06:40:20 +00:00
Configure MathJax overflow handling (#986)
This commit is contained in:
parent
c0232764b3
commit
abd6a790ba
@ -572,6 +572,8 @@ math:
|
|||||||
enable: false
|
enable: false
|
||||||
# Available values: none | ams | all
|
# Available values: none | ams | all
|
||||||
tags: none
|
tags: none
|
||||||
|
# Available values: overflow | scroll | scale | truncate | linebreak
|
||||||
|
display_overflow: scroll
|
||||||
|
|
||||||
katex:
|
katex:
|
||||||
enable: false
|
enable: false
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
if (hexo-config('math.mathjax.enable')) {
|
if (hexo-config('math.mathjax.enable')) {
|
||||||
mjx-container[jax='CHTML'][display='true'], .has-jax {
|
.has-jax {
|
||||||
overflow: auto hidden;
|
overflow: auto hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
source/js/third-party/math/mathjax.js
vendored
12
source/js/third-party/math/mathjax.js
vendored
@ -4,6 +4,12 @@ document.addEventListener('page:loaded', () => {
|
|||||||
if (!CONFIG.enableMath) return;
|
if (!CONFIG.enableMath) return;
|
||||||
|
|
||||||
if (typeof MathJax === 'undefined') {
|
if (typeof MathJax === 'undefined') {
|
||||||
|
const output = {
|
||||||
|
displayOverflow: CONFIG.mathjax.display_overflow
|
||||||
|
};
|
||||||
|
if (CONFIG.mathjax.font_path) {
|
||||||
|
output.fontPath = CONFIG.mathjax.font_path;
|
||||||
|
}
|
||||||
window.MathJax = {
|
window.MathJax = {
|
||||||
tex: {
|
tex: {
|
||||||
inlineMath: { '[+]': [['$', '$']] },
|
inlineMath: { '[+]': [['$', '$']] },
|
||||||
@ -12,7 +18,7 @@ document.addEventListener('page:loaded', () => {
|
|||||||
options: {
|
options: {
|
||||||
renderActions: {
|
renderActions: {
|
||||||
insertedScript: [200, () => {
|
insertedScript: [200, () => {
|
||||||
document.querySelectorAll('mjx-container').forEach(node => {
|
document.querySelectorAll('mjx-container:not([display])').forEach(node => {
|
||||||
const target = node.parentNode;
|
const target = node.parentNode;
|
||||||
if (target.nodeName.toLowerCase() === 'li') {
|
if (target.nodeName.toLowerCase() === 'li') {
|
||||||
target.parentNode.classList.add('has-jax');
|
target.parentNode.classList.add('has-jax');
|
||||||
@ -21,9 +27,7 @@ document.addEventListener('page:loaded', () => {
|
|||||||
}, '', false]
|
}, '', false]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
output: CONFIG.mathjax.font_path ? {
|
output
|
||||||
fontPath: CONFIG.mathjax.font_path
|
|
||||||
} : {}
|
|
||||||
};
|
};
|
||||||
NexT.utils.getScript(CONFIG.mathjax.js, {
|
NexT.utils.getScript(CONFIG.mathjax.js, {
|
||||||
attributes: {
|
attributes: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user