MathML on ereaders
Published on October 13, 2014.
Ereaders are the best gadget to read because of their e-ink screen. Most of the ereaders available in the market support EPUB, a open standard for digital books. The last release of EPUB specification says for mathematical equations must be used MathML.
Unfortunately, none of ereaders available at the market support MathML. (If you know one please let me know, you can contact me by email.)
Note
Ereaders aren’t the same as EPUB readers. You can find at least one EPUB reader that support MathML for all the popular operating system.
Frédéric Wang wrote a small CSS collection to emulate MathML when native support isn’t available and this blog post about trying to use this collection to get MathML on ereaders.
Layout Engine
Briefly, we have two free/open source layout engine: Gecko and WebKit. Gecko has native MathML support and powers Firefox. WebKit also has native MathML support and powers many web browser like Chromium/Google Chrome, Safari and Gnome Web.
Some web browsers, like Chromium/Google Chrome, disable the MathML support from WebKit.
{width=“80%”}
For that reason that Frédéric had to write the CSS that works very well considering CSS’s limitations.
{width=“80%”}
Could we use Frédéric’s CSS for ereaders?
Note
As far as I can tell, most of the ereaders available at the market use WebKit because they are based on Android (e.g. Nook and other from Europe) or the company that develop it has public available code repositories related with WebKit (e.g. Kobo).
Sample
Before test it we need create a small EPUB with MathML. For that we will use Markdown and Pandoc. To start you will need this Markdown file <sample.md> and Frédéric’s CSS file <mathml.css>. :
$ cat sample.md
# MathML Sample
$f(x)$, de uma função tal que $f(w) = \frac{1}{2} e^{x}$.
$f(x)$, de uma função tal que $$f(w) = \frac{1}{2} e^{x}$$.
A integral de Fourier é $f(x) = \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{+\infty} \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{+\infty} f(x) e^{i w x} dx e^{-i w x} dw.$
A integral de Fourier é $$f(x) = \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{+\infty} \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{+\infty} f(x) e^{i w x} dx e^{-i w x} dw.$$
$ pandoc --version
pandoc 1.13.1
$ pandoc -f markdown -t epub --mathml -o sample-mathml.epub sample.md
$ pandoc -f markdown -t epub --mathml --epub-stylesheet=mathml.css -o sample-css.epub sample.md
Note
Download the EPUB files: sample-mathml.epub and sample-css.epub.
Testing - Nook
For Nook Simple Touch, released on 2011 and runs Android 2.1, sample-mathml.epub looks the same as Chromium.
{width=“80%”}
Is impossible to read sample-css.epub because many equations get its own page.
{width=“80%”}
Testing - Kobo
Thanks
Testing on Kobo was possible thanks to Ivan Sichmann Freitas who lent me his device.
For Kobo Aura HD, released on 2013, sample-mathml.epub also looks the same as Chromium.
{width=“80%”}
sample-css.epub didn’t have the same problem from Nook but the result wasn’t the expected.
{width=“80%”}
Future works
- Check if Kobo Web Browser has the same problem with the CSS.
- Try to get the same problem with Chromium.
- Try to improve the CSS?
Tags: