08-06-2024, 07:08 AM | #1 |
Junior Member
Posts: 4
Karma: 10
Join Date: Aug 2024
Device: none
|
XHTML closing tag issue
Simply by parsing and committing an xhtml file, using the container, I see the following changes to the content.
Before parsing: <span x="y"/> <div id="w"/> After committing: <span x="y"></span> <div id="w"></div> Is there a 'tweak' setting or other method I can use to preserve the compact version of for tags with only attributes and no content? |
08-06-2024, 07:43 AM | #2 |
creator of calibre
Posts: 44,202
Karma: 23000010
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No there isn't, IIRC.
|
Advert | |
|
Yesterday, 11:40 AM | #3 |
Junior Member
Posts: 4
Karma: 10
Join Date: Aug 2024
Device: none
|
I have not looked at the Calibre code. Hopefully there is an option on the serializer to use compact closing tags (i.e. <sometag/>) instead of <sometag></sometag>. If this is the case, how difficult do you think it would be to add a tweak to set this option? Is this something you or I can look at? I would need a few hints where to start looking.
|
Yesterday, 11:44 AM | #4 |
creator of calibre
Posts: 44,202
Karma: 23000010
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
This is done deliberately, see line 441 in oeb/base.py
|
Yesterday, 01:20 PM | #5 | |
Resident Curmudgeon
Posts: 75,383
Karma: 133807966
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
Quote:
|
|
Advert | |
|
Today, 06:25 AM | #6 |
Junior Member
Posts: 4
Karma: 10
Join Date: Aug 2024
Device: none
|
I see the comment about some browser based renderers. I wonder if this is still true. I've no idea when this code was written. But my boss needs self closing tags. So if, at line 160 we had:
Code:
def close_self_closing_tags(raw): if self_closing_tags_permitted(): return raw for_unicode = isinstance(raw, str) repl = as_string_type(r'<\g<tag>\g<arg>></\g<tag>>', for_unicode) pat = self_closing_pat(for_unicode) return pat.sub(repl, raw) |
Today, 07:54 AM | #7 |
creator of calibre
Posts: 44,202
Karma: 23000010
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I'm not going to change that as it is a completely cosmetic change that has the potential to break rendering in the real world. You are welcome to run calibre from source and make the change for yourself.
|
Today, 09:47 AM | #8 | |
Junior Member
Posts: 4
Karma: 10
Join Date: Aug 2024
Device: none
|
Quote:
Implementing such a change myself (apart from not having a Linux system to do the build) would mean our Client could no longer install any future Calibre updates. Fingers crossed, best regards Paul |
|
Today, 10:14 AM | #9 |
creator of calibre
Posts: 44,202
Karma: 23000010
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
<tag></tag> is perfectly well formed XML. I suggest you tell your client to read the XML specifications.
You don't need Linux to do a build, indeed you don't need to do a build at all. calibre can run from source without needing building see https://manual.calibre-ebook.com/develop.html I am not going to accept this change in calibre as it has the potential to break things for people for no actual benefit to any calibre user. |
Tags |
xhtml tags |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inserting self closing tags (xhtml) | roger64 | Editor | 2 | 03-04-2018 05:49 AM |
TOC nav.xhtml issue | ebookscovers | Conversion | 1 | 05-06-2017 11:12 AM |
questions on self-closing tags and legal xhtml in epubs | KevinH | ePub | 5 | 04-23-2012 10:12 PM |
Issue closing ebook reader in Linux | hairybiker | Calibre | 8 | 05-31-2011 02:17 PM |
Issue with converting xhtml to epub using Calibre | sg31 | Calibre | 0 | 10-20-2009 06:26 PM |