Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 03-04-2025, 10:25 AM   #1
wanderson
Enthusiast
wanderson began at the beginning.
 
wanderson's Avatar
 
Posts: 28
Karma: 10
Join Date: Jul 2017
Location: Austin TX USA
Device: Kindle Paperwhite Gen 11, Likebook Mars & TCL NxtPaper 11
MathML namespace declaration in .css not "sticking"

I'm editing a equation-heavy epub and I'm using a lot of MathML markups. I'd like for the text to be as economical as possible, so I'd like to avoid this kind of tag:

Code:
<math xmlns="http://www.w3.org/1998/Math/MathML"> ... </math>
and instead use a single namespace declaration in the stylesheet.css, namely:

Code:
@namespace math url(http://www.w3.org/1998/Math/MathML);
which would (theoretically) enable a simpler MathML tag:

Code:
<math> ... </math>
This doesn't seem to be working for me in the Calibre editor / previewer. It may be the case that the namespace is conveyed to the first instance of a <math> tag in a file, but the remaining tags "forget" the namespace designation.

What am I doing wrong? Thanks in advance for any help.
wanderson is offline   Reply With Quote
Old 03-04-2025, 12:17 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,342
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
namespace declarations in CSS do not change the namespace of tags in html. They just allow css tag based selectors to use namespaces.
kovidgoyal is offline   Reply With Quote
Advert
Old 03-04-2025, 12:33 PM   #3
wanderson
Enthusiast
wanderson began at the beginning.
 
wanderson's Avatar
 
Posts: 28
Karma: 10
Join Date: Jul 2017
Location: Austin TX USA
Device: Kindle Paperwhite Gen 11, Likebook Mars & TCL NxtPaper 11
Quote:
Originally Posted by kovidgoyal View Post
namespace declarations in CSS do not change the namespace of tags in html. They just allow css tag based selectors to use namespaces.
So, is there no concise way to have all the <math> tags in a file use a given namespace?
wanderson is offline   Reply With Quote
Old 03-04-2025, 06:39 PM   #4
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,149
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Have you tried modifying the <html> tag at the start of each XHTML file to read:
Code:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:math="http://www.w3.org/1998/Math/MathML">
I haven't done much with books containing MathML but I've seen that structure in a couple of them.

The attached file seems to display happily in Sigil but not in calibre's ebook-editor.
Attached Files
File Type: epub mathml.epub (2.2 KB, 130 views)

Last edited by DNSB; 03-04-2025 at 06:43 PM.
DNSB is offline   Reply With Quote
Old 03-07-2025, 03:49 PM   #5
wanderson
Enthusiast
wanderson began at the beginning.
 
wanderson's Avatar
 
Posts: 28
Karma: 10
Join Date: Jul 2017
Location: Austin TX USA
Device: Kindle Paperwhite Gen 11, Likebook Mars & TCL NxtPaper 11
Quote:
Originally Posted by DNSB View Post
Have you tried modifying the <html> tag at the start of each XHTML file to read:
Code:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:math="http://www.w3.org/1998/Math/MathML">
I haven't done much with books containing MathML but I've seen that structure in a couple of them.

The attached file seems to display happily in Sigil but not in calibre's ebook-editor.
Thanks, DNSB, but I've found out that even in Sigil (and certainly in Calibre's ebook editor preview pane), this doesn't distribute to all the <math> blocks in the file, only the first. The namespace designation must be appended to each block, alas. I therefore consider this matter closed and will do it the verbose way.
wanderson is offline   Reply With Quote
Advert
Old 03-07-2025, 03:57 PM   #6
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,149
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Sounds like a job for a clip.
DNSB is offline   Reply With Quote
Old 03-07-2025, 06:12 PM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,759
Karma: 5706256
Join Date: Nov 2009
Device: many
That Sigil ignores that namespace makes no sense. Adding the mathml namespace prefix "math" to the html tag and then using that prefix "math" for each math tag in the file (ie. each tag becomes math:math) should work. That is what namespace prefixes are for.

More importantly though math tags do NOT need a prefix at all under the html5 xhtml variant used for epub3 according to the spec. The math tag and its contents is autorecognized as a foreign tag (just like the svg tag) and modern parsers should understand it just fine without the need for declaring any namespace prefix for it.

Have you tried without any specific namespace prefix defined for mathml at all?

I wonder if this is a limitation of Qt6's webengine's new built in mathml support in some way?

Update: It is not. To test with Sigil I opened an epub full of mathml and did a global find and replace to remove all of the math tag namespace declarations that said no prefix needed:

ie:
xmlns="http://www.w3.org/1998/Math/MathML"

and made sure no mathml prefix namespace was defined on the html tag.

And sure enough no parsing errors or problems at all. All equations looked as expected.

So no math namespace prefix need be defined and no xmlns="http://www.w3.org/1998/Math/MathML" need be added to math tags as it is properly namespaced by the parser under the html5 xhtml variant used by epubs and by browser engines.

Not sure what problems you are seeing under Sigil.

Last edited by KevinH; 03-07-2025 at 06:31 PM.
KevinH is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre 6.11: "Remove CSS Rules" and "Check Book" Conflicts enuddleyarbl Editor 10 01-08-2023 08:33 AM
In DTD declaration, language other than "EN" will generate warning message. guidaq Sigil 3 04-07-2016 10:48 PM
Touch "sticking" page turn button GreenMonkey Barnes & Noble NOOK 2 10-15-2011 06:23 PM
attribute "scheme" from namespace error in epubcheck 1.0.5 thunderune ePub 15 06-30-2011 10:57 AM
Namespace declaration ChrisI Sigil 1 08-22-2010 06:02 AM


All times are GMT -4. The time now is 09:39 PM.


MobileRead.com is a privately owned, operated and funded community.