![]() |
#1 |
Wannabe Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 426
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
![]()
Hi folks,
How do I get Sigil to render MathML/MathJax the the preview window? I've only just discovered MathML and wanted to have a bit of a tinker. I've got two sample epubs, one from the Calibre documentation and a linear algebra epub from this EPUB 3 samples page, neither of which render anything math like in the preview window. I've also tried creating a new epub3 and putting this following snippet in the body (this from Accessible Publishing Knowledge Base MathML page): Code:
<math xmlns="http://www.w3.org/1998/Math/MathML" alttext="Frac Root a EndRoot Over b EndFrac"> <mfrac> <msqrt> <mtext>a</mtext> </msqrt> <mi>b</mi> </mfrac> </math> I've tried ticking the two boxes ("epubs may access remote resources" and "epubs may use javascript") in the General Settings / Security prefs but no change to preview rendering. I've seen references to MathML in the Sigil forums (eg here and here and this thread), so I figure I must be missing something simple. There's no mention of "math" in the Sigil User's Guide. This is with Sigil 1.5.1 on Windows 10. Last edited by snarkophilus; 03-31-2021 at 08:16 AM. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,356
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Looks like we broke something. It's not working like it should with 1.4.3, either. At least on Windows. Looks like the url for the mathjax javscript file is being blocked. Shoot. Sorry about that. I'll see if I can figure out what version of Sigil it last worked with. We'll get it fixed for the next release, but that may be a bit.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wannabe Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 426
Karma: 2516674
Join Date: Apr 2011
Location: Geelong, Australia
Device: Kobo Libra 2, Kobo Aura 2, Sony PRS-T1, Sony PRS-350, Palm TX
|
Good to know I'm not going (totally) crazy! I upgraded from 1.4.3 to 1.5.1 before posting too because I couldn't get it working there either.
If you can post in this thread when it's fixed, I'll pick up one of the CI builds (if I can recall where they live ![]() |
![]() |
![]() |
![]() |
#4 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
FWIW, this must be a Windows issue.
It works just fine on macOS with 1.3.0, 1.4.3, and 1.5.1. Has anyone tried Linux? See my screenshot. |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,356
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Yeah... it's broken on Linux in 1.5.x, too.
Last edited by DiapDealer; 03-31-2021 at 10:43 AM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
The exact same approach is used to inject user css into preview? Is that broken on Windows and Linux too?
Try his simple example, and the fire up Preview's Inspector and check to make sure the injected mathjax javascript file url is correct in head. If it is, then the issue must be in URLInterceptor as it explicitly allows file calls inside of the mathjax folder. The MainWindow determines both the maxjaxurl which it passes to Preview and the enclosing mathjax folder which URLInterceptor takes from the MainWindow via a GetMathjaxFolder call defined in MainWindow.h. Something there must be broken. |
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,356
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
The injected url is correct. It's percent-encoded, but it always has been, and a quick browser test ensures that the percent-encoded file url can be located/loaded.
I'll do some more testing. |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,356
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I've got to go back to Sigil 1.2.0 for it to work on Windows!?
The issue on Linux is completely different. The MathJax failure is directly tied to me defining a custom temp folder for Sigil. Once I change that back to the automatic default location, MathJax works again in Sigil 1.5.1 on Linux. I'm hoping that can be corrected some time, but it's not a big deal. From what I can see, the url is fine on Windows, too. It's the exact same url as the one used in Sigil 1.2.0 when MathJax was working on Windows. GetMathJaxFolder is identifying the correct folder as well. |
![]() |
![]() |
![]() |
#9 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Hmm, perhaps enable debug in URLInterceptor so we can see what is going on. I am betting some strange drive letter or initial path / nonsense.
|
![]() |
![]() |
![]() |
#10 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
If it is not being blocked, then the issue might be in the URLSchemeHandler loading the resource from the file url. Again perhaps there is an error in converting that file url back to a functioning local file path that can be opened and read from.
|
![]() |
![]() |
![]() |
#11 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,356
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Well the drive letter after the colon is being percent-encoded (file:///C:/) when viewed in inspector, but it always was, even back when mathjax was working.
|
![]() |
![]() |
![]() |
#12 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,356
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
It's definitely being blocked on Windows.
Code:
Failed to load resource: net::ERR_BLOCKED_BY_CLIENT |
![]() |
![]() |
![]() |
#13 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Have you by any chance disabled client javascripts in Sigil's Preferences?
Under Sigil Preferences -> General Settings - > Security: Control Use of Javascript by Epubs check Epubs may use javascript. Then restart Sigil so the new MainWindow will get that new setting. The current one has already opened and its setting is the old one. If I uncheck that and open a new Window (macOS allows that without restarting), then try the example, all I get is "a b". If I enable it (and mathjax is javascript) and then open a new window and try the example it works. Last edited by KevinH; 03-31-2021 at 12:07 PM. |
![]() |
![]() |
![]() |
#14 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
If it was being blocked by our URLInterceptor you would see the following in qDebug:
Code:
// otherwise block it to prevent access to any outside Sigil user file path info.block(true); qDebug() << "Warning: URLInterceptor blocking access to url " << destination; qDebug() << " from " << info.firstPartyUrl(); return; |
![]() |
![]() |
![]() |
#15 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,475
Karma: 5703586
Join Date: Nov 2009
Device: many
|
If that turns out to be the case, we should make Sigil restart after playing with the "may use javascripts" setting at least on Windows and Linux. On macOS, no restart is needed because we can just open a new Window and it will have javascript enabled.
|
![]() |
![]() |
![]() |
Tags |
mathml |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Convert Mathjax to AZW3 | mathbooks | Conversion | 1 | 01-16-2019 10:24 PM |
Calibre mathjax | ELITSIO | Calibre | 7 | 04-01-2017 04:27 AM |
epub and mathjax | vri | Calibre | 24 | 03-31-2017 10:56 PM |
MathJax.epub | phossler | Editor | 8 | 08-23-2015 12:28 PM |
Including MathJax | net-buoy | Sigil | 3 | 02-22-2013 04:44 PM |