|
|
#31 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,097
Karma: 4000789
Join Date: Jan 2017
Location: Poland
Device: Various
|
It's very simple.
But to help you understand it, let's use a real character: the ellipsis. Unicode character: … Numerical entity: & #8230; Named entity: & hellip; Got it? |
|
|
|
|
|
#32 | ||
|
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 462
Karma: 100100
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
|
Quote:
But, trying to relate that to the language used in discusssions is not so evident. Particularly in the User Guide, the terms character, numerical and named seem to be used interchangeably to the point where they obscure the reality of what 'Preserve Entities' actually does. Another example from the User Guide - Quote:
If nothing is in the preserve entities list, the non-breaking space characters remain 'as is', when the files are reformatted with 'mend and prettify'. So what is 'preserved' ? It seems to be a question of familiarity causing incorrect nomenclature to be used at the expense of the meaning. Maybe I'm the only one confused by the language? |
||
|
|
|
|
|
#33 |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,965
Karma: 212736643
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Putting an entity (named or numerical) in the Preserve Entities list means that that entity will never be converted to a character in Code View.
Most of the time, being converted to a character is not a problem (and it's always valid), but many special characters are invisible, or tend to look much like, other normal characters. Preserving them as entities can help them be readily located in Code View. Sigil's gumbo parser wants to convert all entities to characters. Adding them to the Preserve Entities list allows users to preserve those entities that they'd rather not be converted to characters in Code View. Last edited by DiapDealer; 11-16-2026 at 08:22 AM. |
|
|
|
|
|
#34 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,097
Karma: 4000789
Join Date: Jan 2017
Location: Poland
Device: Various
|
IMHO (and probably according to Sigil's developers), phrase "Preserve Entities" in Sigil's Preferences means exactly this:
"If character X is written in any form (numeric entity, named entity, unicode character), then write it as an entity from the list below." Thus, "Preserve Entities" = "Protect the entities on my list, and while you're at it, convert other forms to these specific entities." |
|
|
|
|
|
#35 | |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
Quote:
Named entities are illegal in epub3 (except for 5 xml named enties for < > & " ') so only numeric entities are allowed. All Preserve Entities does is allow the user to specify which characters should be converted back to entities after every use of gumbo (in other words which to preserve, thus the name) and if so which entity form you want. Newer versions of Sigil's Preserve Entities defaults to only preserve the nbsp as a numeric entity since it can not be seen in CodeView and is valid in both epub2 and epub3. Hope this helps. FWIW, Volunteers created the Sigil User Guide and volunteers help improve and maintain it. PRs to improve the User's guide are welcome. Last edited by KevinH; 11-16-2026 at 09:15 AM. |
|
|
|
|
|
|
#36 |
|
Enthusiast
![]() Posts: 41
Karma: 10
Join Date: Oct 2020
Device: none
|
There's a bug in it then; I added ​ and yet my zero-width spaces are still getting clobbered.
[quick note, posting from work] |
|
|
|
|
|
#37 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
Getting clobbered by using what command, menu, or tool? And by clobbered, do you mean converted to its character equivalent or converted incorrectly to some other character, or removed?
|
|
|
|
|
|
#38 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
I just tested Preserve Entities with the zwsp character and it was preserved properly after using gumbo (Mend) when & #x200B; was added to the preserve entities list.
So perhaps it got "clobbered" by the sigil_bs4 element.py decodexml_contents() bug we just fixed in this thread? So unless you can give us a specific sequence of commands to reproduce the potential bug, I can't recreate this with current Sigil master as basic Preserve Entities is working. |
|
|
|
|
|
#39 | |
|
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 29,965
Karma: 212736643
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Using the released Sigil 2.8.6 (before your recent fix), the following steps (when substituting ​ for  ) causes the ​ entity to be converted to a character. I had added ​ to the Preserve Entities list, but I'm not sure that's even used when it's the ncx??
When entering the ​ entity into an xhtml file and running mend and prettify, the entity was preserved as expected (with the official Sigil 2.8.6). After pulling in your changes and rebuilding, the same test and ncx move still causes the ​ entity to be converted to its character equivalent. Quote:
|
|
|
|
|
|
|
#40 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,097
Karma: 4000789
Join Date: Jan 2017
Location: Poland
Device: Various
|
That's not really surprising. This commit essentially changed the definition of a "numeric entity" by defining IS_NUMERIC_ENTITY.
|
|
|
|
|
|
#41 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
It added the regex for numeric entities, it did not replace or change the general entity regex. The not inverts that piece of code to never mess with numeric entities in that patch.
Please note, the ncx is not parsed by gumbo as it is pure xml not xhtml. So zwsp will not be preserved as an entity if copied into the ncx from xhtml before the preserve entities step is done if gumbo is used to parse the nav to get strings to create the nav from. The preserve entities step is only done on xhtml after serialization as parsing always converts it to a pure character. So this is a bit of a corner case but it is expected given how Preserve Entities works. There is not a Sigil tool to preserve entities in pure xml like the ncx that is meant to be machine read. Last edited by KevinH; 11-16-2026 at 02:16 PM. |
|
|
|
|
|
#42 |
|
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,097
Karma: 4000789
Join Date: Jan 2017
Location: Poland
Device: Various
|
You're right. I'll build a new Sigil right away and check it out.
|
|
|
|
|
|
#43 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
But if he is using this in index files which are xhtml and it goes away, then there is a missing call to preserve entities someplace.
|
|
|
|
|
|
#44 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
Okay, I could recreate what DiapDelaer is seeing on my Mac. The ​ numeric entity even when placed in the ncx directly is converted to its character code by the ncx parser (lxml with pure xml parser) and since there is no PreserveEntities run on pure xml (mainly because both the ncx and opf are meant to be machine readable and not read by users) it stays as a character.
If you really need numeric entities and not the actual character in the NCX, you can use Find and Replace to fix this as follows: Find: \x{200b} Replace: ​ Target: NCX File (or Current File if the NCX is open in CodeView) Mode: Regex Then hit Replace All |
|
|
|
|
|
#45 |
|
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
|
It seems lxml is only converting some numeric entities when it parses pure xml. It left & #160; as an entity string but converts & #x200b; always to pure character form.
Not really sure why lxml is deciding to do it that way. I will look to see if there is any way to control that aspect of parsing via python lxml for pure python. |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| No Table of Contents and "This HTML file is larger than 260 KB" Error | rosewood | Conversion | 13 | 02-07-2023 12:58 PM |
| PRS-T3 "Table of contents" button on every page | Leon74 | Sony Reader | 2 | 01-04-2014 12:48 PM |
| Change name of autogenerated "Table of Contents" | Dzoni | Conversion | 7 | 03-16-2011 04:44 AM |
| Generating a rough "table of contents" | Vanguard3000 | Calibre | 5 | 01-09-2011 11:31 PM |
| TOO SLOW to open "Table of Contents" | mdhuang | Sony Reader | 16 | 09-06-2007 11:29 PM |