Skip to content

Commit 79f1d28

Browse files
committed
docs: render math in Jupyter notebooks (MathJax dollar delimiters)
The MathJax config only processed pymdownx.arithmatex spans (\(...\) on .md pages). mkdocs-jupyter emits notebook markdown math as raw $...$, which was neither delimited nor allowed to be processed, so it showed as literal text. Accept both delimiter styles (\(...\)/\[...\] for arithmatex, $...$/$$...$$ for notebooks) and drop the arithmatex-only processHtmlClass restriction so MathJax scans the whole page (it still skips <pre>/<code>, so $ in code is untouched). Both .md and notebook math now render.
1 parent 9288e6f commit 79f1d28

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎docs/javascripts/mathjax.js‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
// MathJax config for Material for MkDocs + pymdownx.arithmatex (generic mode).
1+
// MathJax config covering both rendering paths on this site:
2+
// - Markdown pages via pymdownx.arithmatex (generic): math arrives as
3+
// \(...\) / \[...\] inside `arithmatex` spans.
4+
// - Jupyter notebooks via mkdocs-jupyter: math arrives as raw $...$ / $$...$$.
5+
// So we accept both delimiter styles and let MathJax scan the whole page (it
6+
// skips <pre>/<code>/<script> by default, so $ in code is untouched).
27
window.MathJax = {
38
tex: {
4-
inlineMath: [["\\(", "\\)"]],
5-
displayMath: [["\\[", "\\]"]],
9+
inlineMath: [["\\(", "\\)"], ["$", "$"]],
10+
displayMath: [["\\[", "\\]"], ["$$", "$$"]],
611
processEscapes: true,
712
processEnvironments: true,
813
},
9-
options: {
10-
ignoreHtmlClass: ".*|",
11-
processHtmlClass: "arithmatex",
12-
},
1314
};
1415

1516
// Re-typeset on Material's instant-navigation page loads.

0 commit comments

Comments
 (0)