# Testing the EPUB3 / MathML Support of the E-Book Reader

One subject which I wrote about before was, that while the MathML standard exists, as well as E-Book Readers capable of parsing at least a subset of the EPUB3 standard, most E-Book Readers that people can download and use fully, for free, under Android, fail to do so.

Specifically, I was disappointed that ‘FBReader’ fails to do so. OTOH, I had already written that ‘Infinity Reader’, an Android app that requires an in-app purchase to get rid of the advertisements, at least does support that part of the standard.

The following is a document, which the reader of this blog can use, to test this ability:

http://dirkmittler.homeip.net/MathML-Test_1.epub

(Update 1/31/2020, 20h05 … )

(As of 1/29/2020, 14h30 : )

On this blog, unless I really need to typeset Math perfectly, I’ve been using the EPUB2 posting-tag, and encoding Math to standard HTML, without any MathML. In case the reader did not know, an EPUB File is really a collection of HTML Files (in addition to other file-types one would find on a Web-site, as well as a manifest file), that have been Zipped. (:2) When I tell my software to output Math notation to this form of HTML, what it will often do is to generate PNG Image Files, and to flow those in-line with text. And the evil with that is, that an image flowed in that way, can be commanded by the HTML in question, or the CSS File (more probably), to align with the text, so that the text will be at the Top, in the Middle, or with the Bottom of the image. Why is that a problem? Because even though I have given the appropriate HTML directives in the past, the way some EPUB-capable E-Book Readers render it, ignores the specific instructions…

… (:1)

One step which I always take, is to preview the (main) HTML File using Firefox, before generating an EPUB File.

When I do no explicit editing of the HTML first, it’s even possible that the LaTeX utilities leave the question unanswered.

The result is that images from the same origin will seem to be aligned at their Top with the text, when just viewed with ‘Firefox’, and at the Bottom when viewed with ‘FBReader’… What this does is, to connotate wrong Mathematical meanings from the reader. An image representing a matrix should be aligned Middle, to denote vector-multiplication, but if there is text in its upper-right-hand corner, this implies an exponent, which is rare, but also plausible for matrices. Also, the letter ‘T’ may legitimately appear as a superscript of matrices. A subscript will be taken to mean an array index. But the text following a matrix may simply appear superscripted or subscripted, due to incorrect vertical alignment.

A glyph that just hangs below a line of text, simply looks weird…

… (:1)

All that could be avoided, if I first encoded my Math to XHTML with MathML, and then have that published to an EPUB File. In that case, it was revealed that Firefox’s native MathML support was actually weaker, than what the same browser could render correctly, using ‘MathJax’

FWIW, I think that the way the more-recent FBReader renders flowed images, is still in one position, but is now hinted as being somewhere between Middle and Bottom, just so that all imaginable meanings remain imaginable, and that way, I’m even less-compelled to use XHTML with MathML…

I suppose that another question this subject poses would be, ‘Why does Dirk use the command-line:

htlatex $1 ‘xhtml,charset=utf-8,mathml’ … When the command-line: make4ht -u$1 ‘mathml,html5′ …

Was already suggested to him and works fine?’ And my answer would be, that I can use ‘htlatex’ -based command-lines on a wider variety of .TEX Files, than I can use ‘make4ht’ on, including, SageTex -originated .TEX Files. That last ability eluded me until recently, but is now fully in my grasp.

Finally, I also possess scripts which will compile .TEX Files to MathJax. But while this is a wonderful tool to employ when HTML is being served out on the Web, the HTML that results is not suitable for inclusion into an EPUB File because an E-Book Reader will not grab the additional scripts from a Content Delivery Network. In fact, E-Book Readers need to be able to view EPUB Files when offline.

Further, the publisher cannot assume that JavaScript will ever run in an E-Book Reader.

(Update 1/30/2020, 16h40 : )

1:)

Even though I have included some screen-shots of the EPUB-File editing tool ‘Sigil’, the only purpose here is to reveal the internal structure of EPUB Files. I rarely use Sigil, except on occasions when I do feel I need to edit the HTML / XHTML.

(Update 1/31/2020, 20h05 : )

2:)

I have read advice given by certain other people, which stated, that another user should rename the .EPUB-File to a .ZIP-File, and then observe, that the contents of the .ZIP-File thus created become viewable. The biggest problem with that sort of advice is the fact that Windows will hide the filename extension of known file-types, i.e., of file-types for which applications have put entries in the Windows Registry, to be able to open. Hence, if the filename is:

Integral1_x-1.epub

What the Windows Explorer will display instead is the text:

<Integral1_x-1>

…Along with an icon (assuming that software is installed, that can open .EPUB-Files). The user is expected to recognize file-types, entirely through the icon. Hence, if most Windows users try to rename the file, they will first left-click on the icon, to select it, and then left-click on its displayed text, to rename that. And the filename that will result is:

Integral1_x-1.zip.epub

Just because, Windows Explorer is then displaying the text:

<Integral1_x-1.zip>

And the icon will stay the same.

What all Linux desktop managers do is to display the full filename, with its extension, as well as an icon. There is also a setting that causes Windows Explorer to do so, but most people leave that off, as it is by default. Another Linux behaviour, aimed at reducing the risk of accidentally rendering files inoperative, when the icon is right-clicked and the context-menu entry left-clicked, to ‘Rename’, Linux will initially highlight only the part of the filename that precedes the filename extension. This way, if a user really wanted to rename the extension, he would first need to deselect the main part of the filename, and then re-select it together with its extension, all of which requires action with the mouse.

Otherwise, any text which is just typed in replaces the part of the filename that precedes the extension, and that precedes the dot.

Further, the graphical file managers run as user, not as root, which means that they do not have the privileges to rename system files. Even though, with some configurations, limited editing of system files from the graphical interface is possible, this is no longer standard. Their main domain is in the user data.

Enjoy,

Dirk