From 68465f0d8b316a81c5255d6f4a156de40fa4bc50 Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sun, 14 Aug 2022 17:46:49 +0200 Subject: [PATCH 1/2] configure arithmatex for v3 as documented in https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown-extensions/#arithmatex --- docs/javascripts/mathjax.js | 17 +++++++++++++++++ mkdocs.yml | 10 +++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 docs/javascripts/mathjax.js diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js new file mode 100644 index 00000000..73e99721 --- /dev/null +++ b/docs/javascripts/mathjax.js @@ -0,0 +1,17 @@ +window.MathJax = { + tex: { + inlineMath: [["\\(", "\\)"]], + displayMath: [["\\[", "\\]"]], + processEscapes: true, + processEnvironments: true + }, + options: { + ignoreHtmlClass: ".*|", + processHtmlClass: "arithmatex" + } + }; + + document$.subscribe(() => { + MathJax.typesetPromise() + }) + \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 021e893f..870e861b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -18,9 +18,12 @@ theme: accent: 'red' extra_css: - - 'stylesheets/extra.css' + - stylesheets/extra.css extra_javascript: - - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML' + - javascripts/mathjax.js + - https://polyfill.io/v3/polyfill.min.js?features=es6 + - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js + markdown_extensions: - admonition - pymdownx.highlight: @@ -28,7 +31,8 @@ markdown_extensions: linenums_style: table - pymdownx.superfences - pymdownx.inlinehilite - - pymdownx.arithmatex + - pymdownx.arithmatex: + generic: true - footnotes extra: From 5eb0a8fb89dc9444ef625310f774c0d18aa4996c Mon Sep 17 00:00:00 2001 From: Philipp Salvisberg Date: Sun, 14 Aug 2022 17:47:36 +0200 Subject: [PATCH 2/2] use arithmatex v2 configuration for PDF --- tools/run-in-container/genpdf.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/run-in-container/genpdf.sh b/tools/run-in-container/genpdf.sh index 6787b2b2..ff017f7e 100755 --- a/tools/run-in-container/genpdf.sh +++ b/tools/run-in-container/genpdf.sh @@ -8,6 +8,7 @@ function create_target_dir(){ function copy_resources() { cp ${DATA_DIR}/mkdocs.yml ${TARGET_DIR}/mkdocs.yml cp -r ${DATA_DIR}/docs/images ${TARGET_DIR}/docs + cp -r ${DATA_DIR}/docs/javascripts ${TARGET_DIR}/docs/javascripts cp -r ${DATA_DIR}/docs/stylesheets ${TARGET_DIR}/docs/stylesheets } @@ -19,7 +20,12 @@ function copy_resources() { # with some nice features for the HTML version. function fix_mkdocs_yml() { mv ${TARGET_DIR}/mkdocs.yml ${TARGET_DIR}/mkdocs.ori.yml - sed -e 's/linenums_style: table/linenums_style: pymdownx-inline/g' ${TARGET_DIR}/mkdocs.ori.yml > ${TARGET_DIR}/mkdocs.yml + sed -e 's/linenums_style: table/linenums_style: pymdownx-inline/g' ${TARGET_DIR}/mkdocs.ori.yml | \ + sed -e 's|javascripts/mathjax.js|https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML|g' | \ + sed -e 's| - https://polyfill.io/v3/polyfill.min.js?features=es6||g' | \ + sed -e 's| - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js||g' | \ + sed -e 's/pymdownx.arithmatex:/pymdownx.arithmatex/g' | \ + sed -e 's/ generic: true//g' > ${TARGET_DIR}/mkdocs.yml } function create_cover() {