Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 11-16-2026, 05:54 AM   #31
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
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?
BeckyEbook is offline   Reply With Quote
Old 11-16-2026, 07:19 AM   #32
philja
Evangelist
philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!philja rocks like Gibraltar!
 
Posts: 462
Karma: 100100
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
Quote:
Originally Posted by BeckyEbook View Post
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?
Yes, thankyou Becky. I did understand that already.

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:
When you run Mend (Tools=>Reformat HTML=>Mend All HTML Files), Sigil automatically converts all character entities to Unicode characters unless they are included in the Entities to Preserve list.
From my experience, Sigil converts a 'Unicode Character' (for example a non-breaking space entered via Insert Special Characters) to a NUMERICAL character, & #160; (without the space), when & #160; is added to the preserve entities list.

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?
philja is offline   Reply With Quote
Old 11-16-2026, 07:52 AM   #33
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
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.
DiapDealer is offline   Reply With Quote
Old 11-16-2026, 07:53 AM   #34
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
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."
BeckyEbook is offline   Reply With Quote
Old 11-16-2026, 09:03 AM   #35
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: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by BeckyEbook View Post
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."
Exactly! Mend or Mend and Prettify or any tool that uses gumbo to parse xhtml inside Sigil converts all entities to their character equivalents. This is 100% correct. But many epub2 devs love and use named entities to help them find things or enter characters without using Insert Special Characters. They can use Numeric Entities as well if they prefer.

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.
KevinH is offline   Reply With Quote
Old 11-16-2026, 10:33 AM   #36
Simons Mith
Enthusiast
Simons Mith began at the beginning.
 
Posts: 41
Karma: 10
Join Date: Oct 2020
Device: none
There's a bug in it then; I added &#x200B; and yet my zero-width spaces are still getting clobbered.
[quick note, posting from work]
Simons Mith is offline   Reply With Quote
Old 11-16-2026, 10:39 AM   #37
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: 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?
KevinH is offline   Reply With Quote
Old 11-16-2026, 11:01 AM   #38
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: 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.
KevinH is offline   Reply With Quote
Old 11-16-2026, 01:35 PM   #39
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
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 &#x200B; for &#160;) causes the &#x200B; entity to be converted to a character. I had added &#x200B; to the Preserve Entities list, but I'm not sure that's even used when it's the ncx??

When entering the &#x200B; 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 &#x200B; entity to be converted to its character equivalent.

Quote:
Originally Posted by KevinH View Post
The faster way to test this is:

1. open any epub2 and add & #160; (without the space after the &) in any text value entry

or

open any epub3 and edit the nav to add & #160; (without the space after the &) in any nav text entry and then delete and recreate the NCX using the epub3 tools

2. Right click in BookBrowser on the ncx and select Move to move it either up or down one directory level

That is enough to cause SourceUpdates to be called on the ncx which in turn invokes sigil_bs4/elment.py in decodexml_contents which is what has the bug.

This code stems from the epub2 only timeframe and changed the leading & of *named* entities which are illegal in pure xml like the ncx by converting the leading & to & amp; thereby disabling them.

When epub3 came along and numeric entities became all the rage and named entities became illegal, we did not modify the code in sigil_bs4/element.py to properly allow numeric entities through untouched.

I have just pushed the code to master to fix this.

Thank you for the bug report.

ps. Restructure to Sigil Norm simply was a complex way of invoking SourceUpdates on an ncx.
DiapDealer is offline   Reply With Quote
Old 11-16-2026, 01:48 PM   #40
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
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.
BeckyEbook is offline   Reply With Quote
Old 11-16-2026, 02:06 PM   #41
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: 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.
KevinH is offline   Reply With Quote
Old 11-16-2026, 02:09 PM   #42
BeckyEbook
Wizard
BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.BeckyEbook ought to be getting tired of karma fortunes by now.
 
BeckyEbook's Avatar
 
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.
BeckyEbook is offline   Reply With Quote
Old 11-16-2026, 02:13 PM   #43
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: 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.
KevinH is offline   Reply With Quote
Old 11-16-2026, 02:39 PM   #44
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: 10,271
Karma: 7640672
Join Date: Nov 2009
Device: many
Okay, I could recreate what DiapDelaer is seeing on my Mac. The &#x200b; 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: &#x200b;
Target: NCX File (or Current File if the NCX is open in CodeView)
Mode: Regex

Then hit Replace All
KevinH is offline   Reply With Quote
Old 11-16-2026, 02:48 PM   #45
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: 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.
KevinH is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 01:10 AM.


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