Forum How do I...?

How to work with MathJax?

emece
Hi all,

I'm trying to use MathJax inside Prince, to no avail, though.

Simply adding:
  <script type="text/javascript" id="MathJax-script" async
    src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
  </script

inside the <head> turns Prince into reporting: Reference Error: no such property: Map

Variant tex-svg-full.js of MathJax throws error: regexp syntax error: ^-(?=[\s_},;\]

I've googled about PrinceXML + MathJax and found some old posts about problems, but I understood that all issues were fixed time ago. Thus, am I doing something wrong?

Thanks & regards.
hallvord
Hi, I've spent some time on figuring out why MathJax fails to run over the last few months. There are still some issues unfortunately. There are a couple of core fixes I'm waiting for but I have workarounds that will make it run. However, I have not tested the text-svg variant, and the output from the version I got to run still looks somewhat messy..

I'm still investigating and if I get a good compat shim script done I will share it - though maybe Mike & co will fix the core issues even faster than I manage to analyse it :)

(The quoted code does not look like a valid regexp, but it is probably just truncated. I will see if I can find the full thing in MathJax's source code).

Announcement: repos for tests/utils

emece
Hi,

I finally managed to get the PDF first running the html thru the Chrome browser (to cope with MathJax v2.7) and then typesetting it with PrinceXML (not enabling JavaScript).

I've took two approaches: one simply uses the Chrome (in headless mode) & PrinceXML CLI; the other uses Selenium+Python. For this later approach the thread "Using MathJax with PrinceXML" was really useful.

Not the most desirable solution, but it works.

Regards.