The release tarballs contain an es5/ directory with the actual mathjax
code. However, when building against a system mathjax it is likely the
es5/ directory is skipped and the directory name is just
/usr/share/mathjax/
Detect this by moving the es5/ component to the definition of the
mathjax source root, but only appending it if the --path-to-mathjax
actually contains such a directory.
version 3 is more performant, smaller and simpler to integrate, without
monkeypatching. On the down side, it does not do line breaking, as yet.
Note that only the viewer is currently ported
There is actually no real consequential change here, because the update
is a trivial bugfix that doesn't affect calibre's use, but let's do it
anyway because it is both simple and harmless.
Some mathjax distributions come with the unpacked versions removed as
per the upstream instructions for optimizing an installation. Only use
the unpacked versions if they exist; otherwise fallback on the packed
versions.
Also filter the .woff files to make sure they are actually .woff files,
since they may be files like fonts.dir, fonts.scale, .uuid (created by
xorg-mkfontdir, xorg-mkfontscale, fontconfig).
Improves performance for local clients such as PDF output and the
viewer. Since we have now removed the old unbundled mathjax, the file
count in the resources directory does not go up too much.