pressbooks / ideas

Ideas for Pressbooks.
GNU General Public License v3.0
12 stars 4 forks source link

Use Mathjax-generated SVG output for PDF & EPUB exports #190

Closed dac514 closed 4 years ago

dac514 commented 5 years ago

Research if it's possible.

Some links to start:

Related to: https://github.com/pressbooks/ideas/issues/189

dac514 commented 5 years ago

Working our way backwards through the PB Latex code, it's more or less a URL that calls a Wordpress server:

<img class="test-image" src="https://s0.wp.com/latex.php?latex=%5Cdisplaystyle+P_%5Cnu%5E%7B-%5Cmu%7D%28z%29%3D%5Cfrac%7B%5Cleft%28z%5E2-1%5Cright%29%5E%7B%5Cfrac%7B%5Cmu%7D%7B2%7D%7D%7D%7B2%5E%5Cmu+%5Csqrt%7B%5Cpi%7D%5CGamma%5Cleft%28%5Cmu%2B%5Cfrac%7B1%7D%7B2%7D%5Cright%29%7D%5Cint_%7B-1%7D%5E1%5Cfrac%7B%5Cleft%281-t%5E2%5Cright%29%5E%7B%5Cmu+-%5Cfrac%7B1%7D%7B2%7D%7D%7D%7B%5Cleft%28z%2Bt%5Csqrt%7Bz%5E2-1%7D%5Cright%29%5E%7B%5Cmu-%5Cnu%7D%7Ddt&amp;bg=T&amp;fg=000000&amp;s=3&amp;zoom=1" alt="Test Image">

Code:

Breakdown:

https://*/latex.php ? latex=URLENCODEDLATEX & bg=BACKGROUNDCOLOR & fg=FOREGROUNDCOLOR & zoom=SIZE

Idea:

Write a small node.js service that is a drop in replacement for <img src=

Technically <img src= can be a SVG. Does it work in epub2 and mobi? If yes, use svg, if no, convert to png.