electricbookworks / electric-book

A Jekyll template for creating books in multiple formats
https://electricbookworks.github.io/electric-book
GNU General Public License v3.0
117 stars 45 forks source link

Convert MathJax to SVG for epub using (gulp-)mathjax-node #198

Closed arthurattwell closed 5 years ago

arthurattwell commented 6 years ago

Epub readers that support Javascript well can render MathJax just fine (surprisingly, Adobe Digital Editions). But other readers can't, including Kindle via Kindlegen.

We might be able to include a processing step using mathjax-node or gulp-mathjax-node to turn the maths into PNG (using mathjax-node) or SVG (using gulp-mathjax-node, which doesn't provide PNG rendering).

arthurattwell commented 6 years ago

We may also need mathjax-node-svg2png.

arthurattwell commented 6 years ago

These resources will be useful:

https://github.com/pkra/mathjax-node-page https://www.npmjs.com/browse/depended/mathjax-node-page https://github.com/pkra/mathjax-node-page/issues/14 https://www.princexml.com/forum/topic/2971/using-mathjax-with-princexml https://github.com/roman-spiridonov/gulp-mathjax-page/blob/master/README.md https://github.com/roman-spiridonov/gulp-plugin-fabric https://github.com/pkra/mathjax-node-page/pull/50

arthurattwell commented 5 years ago

Good progress on this in this branch.

So far, I have math working in PDF on Windows without PhantomJS. The output script uses gulp + mathjax-node-page to convert TeX to MathML before passing the HTML to Prince. It's much faster than using PhantomJS and the rendered math looks better. We'll need lots of testing in the wild to see where and whether we encounter issues with fonts.

Still to do:

arthurattwell commented 5 years ago

Work-in-progress notes: