Importing mml-svg.js into EPUB3 content doc prevents Apple Books pagination

35 views
Skip to first unread message

Christian Roth

unread,
Feb 22, 2024, 6:08:26 AMFeb 22
to MathJax Users
Hello,

as soon as I import mml-svg.js (any version, tried 3.x and latest 4.0 beta) of MathJax into an EPUB3 content XHTML document, Apple Books refuses to paginate that document. There need not be a MathML formula in that page at all, merely adding the script prevents the pagination.
Has anyone run into this as well, is there a solution? 

Details:
I downloaded the MathJax-4.0.0-beta.4 .
I added mml-svg.ja to the EPUB under /js/, and added the following line to the OPF manifest:

    <item id="script1" href="js/mml-svg.js" media-type="text/javascript" />

I added the "scripted" and "mathml" properties to the content document in the manifest:

    <item id="chapter-1" href="chapter-1.xhtml" media-type="application/xhtml+xml" properties="scripted mathml" />

In the content document "chapter-1.xhtml", I include the mml-svg.js like this:

<script src="js/mml-svg.js"></script>


The content document does not contain any MathML – still, Apple Books (Version 6.2 (6030) on macOS) does not paginate the content document - it only displays the first "page", and also does not show its usual "1/x" page position info.

In the Console, the nearest possibly relevant line I can find is:

fault 16:51:45.363090+0100 Books com.apple.iBooks multi-js evaluation failure - Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=2, WKJavaScriptExceptionMessage=TypeError: null is not an object (evaluating 't.cssValueType'), WKJavaScriptExceptionColumnNumber=5644, WKJavaScriptExceptionSourceURL=ibooks-script:content_support.js, NSLocalizedDescription=A JavaScript exception occurred}

which looks like there is occurring some exception during processing of the content the content document, but I am not sure if this might be related to the MathJax library.

I am attaching the EPUB I used for testing. It does not paginate for me as attached. It does paginate in Apple Books when I comment out the <script src="js/mml-svg.js"></script> line from the content document.

What could be the issue?

Thanks so much,
Christian
MathJax import prevents page turning.epub

Davide Cervone

unread,
Feb 23, 2024, 9:56:57 AMFeb 23
to mathja...@googlegroups.com
The error message you provide indicates that the problem is coming from iBooks-script:content_support.js and that it is trying to take the cssValueType from a null object.  This is a file provided by Apple, so is outside of our control.  You may need to report the bug to them.

This page


indicates that the cssValueType is deprecated and may not be supported in most browsers.  For example, it is not available in Firefox.  When I open your pub file in Apple Books v4.4, and older version that you are using, it paginates fine.  So I suspect that somewhere between Books 4.4 and 6.2, the support for the infrastructure for cssValueType has changed, and Apple didn't update their content_support.js file to accommodate that.

Since this value is used to analyze CSS rules, it appears that content_support.js is scanning the stylesheets on the page, and since MathJax does insert stylesheets for its use, that may be what is tripping up content_support.js.

Have you considered pre-processing the xhtml pages rather than running MathJax in them directly?  You could use a program like tex2svg-page from the MathJax-demos-node repository, say the one at


to pre-process the pages.  Then you won't have to worry about including MathJax at all.  Perhaps that will work better for you.

Davide


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mathjax-users/11e5a4d2-03ea-4737-bfb5-3c51ecffc1efn%40googlegroups.com.
<MathJax import prevents page turning.epub>

Christian Roth

unread,
Mar 11, 2024, 5:45:17 AMMar 11
to MathJax Users
Thank you Davide.

I hadn't considered the pre-processing route as I really wanted to make it work as described. But as it turns out, that won't work reliably across the various EPUB reader implementation, so yes, then the pre-processing will be my next try.

I have reported the issue against Apple Books (Apple Feedback Assistant ID: FB13659136, Subject "Apple Books fails to paginate EPUBs (when MathJax is imported)"), but I'm not really hoping for much :-/ 

Thank you,
Christian

Reply all
Reply to author
Forward
0 new messages