openzim / mindtouch

libretexts.org to ZIM scraper
GNU General Public License v3.0
0 stars 0 forks source link

Apply proper MathJax #9

Closed benoit74 closed 2 days ago

benoit74 commented 3 weeks ago

Once #7 is implemented, we need to properly install MathJax, i.e. proper version and configuration.

Both seems to be present in page content on the API, in the tail attribute.

{
...,
"tail": "<!-- Google tag (gtag.js) -->\r\n<script async=\"async\" src=\"https://www.googletagmanager.com/gtag/js?id=G-QBY3PCNWX9\"></script>\r\n<script>/*<![CDATA[*/\r\n  window.dataLayer = window.dataLayer || [];\r\n  function gtag(){dataLayer.push(arguments);}\r\n  gtag('js', new Date());\r\n\r\n  gtag('config', 'G-QBY3PCNWX9');\r\n/*]]>*/</script>\r\n\r\n<script type=\"text/x-mathjax-config\">/*<![CDATA[*/\r\n  MathJax.Ajax.config.path[\"mhchem\"] =\r\n  \"https://cdnjs.cloudflare.com/ajax/libs/mathjax-mhchem/3.3.2\";\r\n  MathJax.Hub.Config({ jax: [\"input/TeX\",\"input/MathML\",\"output/SVG\"],\r\n  extensions: [\"tex2jax.js\",\"mml2jax.js\",\"MathMenu.js\",\"MathZoom.js\"],\r\n  TeX: {\r\n    extensions: [\"autobold.js\",\"mhchem.js\",\"color.js\",\"cancel.js\", \"AMSmath.js\",\"AMSsymbols.js\",\"noErrors.js\",\"noUndefined.js\"]\r\n  },\r\n    \"HTML-CSS\": { linebreaks: { automatic: true , width: \"90%\"}, scale: 85, mtextFontInherit: false},\r\nmenuSettings: { zscale: \"150%\", zoom: \"Double-Click\" },\r\n         SVG: { linebreaks: { automatic: true } }});\r\n/*]]>*/</script>\r\n\r\n<script type=\"text/javascript\" async=\"true\" src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML\"></script>"
}

So MathJax is not something supposed to be applied unconditionally on all pages (especially if we want the scraper to stay generic). We could theoretically have different MathJax version on same website.

It is however clear that we have other stuff on this attribute (here Google Tag). Maybe we should just clean / keep only mathjax related stuff.