futurepress / epub.js

Enhanced eBooks in the browser.
http://futurepress.org
Other
6.5k stars 1.11k forks source link

Can not render the math equation #1301

Open rfhits opened 2 years ago

rfhits commented 2 years ago

the book: "Fundamentals-of-Computer-Graphics_5th-edition.epub"

the equation in 2.1.3 Logarithms:

y = \log_{a}{x}

rendering result of epub.js:

image

should be rendered as:

image

the size of this epub file is 32MB, so I put it in the google dirve: https://drive.google.com/file/d/1snuFibTRnWjLmjUM_q_jKSJ5OG8Rx7_v/view

johnfactotum commented 2 years ago

When using a browser engine that doesn't support MathML yet (i.e. Chromium), you need to use something like MathJax. See https://github.com/futurepress/epub.js/blob/master/examples/mathml.html.

rfhits commented 2 years ago

I tried. I replace the book url, but the math equation remains the same.

johnfactotum commented 2 years ago

The example is broken. It needs to be updated to set allowScriptedContent to true. See https://github.com/futurepress/epub.js/blob/master/README.md#scripted-content

rfhits commented 2 years ago

not work.

I notice that some requests were sent by the mathjax, does it matters?

tree of my files:

.
|- ajax-loader.gif
|- epub.js
|- epubjs-mathml.html
|- examples.css
|- Fundamentals-of-Computer-Graphics_5th-edition.epub

some requests from mathjax:

image

files_202211152014.zip

johnfactotum commented 2 years ago

I notice that some requests were sent by the mathjax, does it matters?

Yeah, if you're using the CDN then it should be fetching resources from the CDN, not 127.0.0.1:5500. I don't know what could be causing this, though.

But at least the examples/mathml.html page works if you clone Epub.js, run npm install, and open the page directly in the browser. So in your case, probably either MathJax isn't included properly or some additional configuration is required for it to resolve resources correctly.