Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 09-26-2026, 12:15 AM   #1
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 65
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
Automatic fix of an ID name causes loss of CSS styling

When Calibre Editor's Check Book function reports an invalid ID, the automatic correction "Replace this id with a randomly generated valid id" (or "Try to automatically fix all fixable errors") changes the id attribute in the XHTML file, but does not update CSS selector referring to the ID.

As a result, the CSS rule no longer matches the element and its formatting is silently lost.

example:
xhtml:
Code:
<p id="_example">This paragraph is formatted by CSS.</p>
css:
Code:
#_example {
    text-align: right;
    font-weight: bold;
}
after autofix:
xhtml:
Code:
<p id="uiIKYKleNpAABQhFyzTceGC">This paragraph is formatted by CSS.</p>
css:
(without change)

expected behaviour:
css:
Code:
#uiIKYKleNpAABQhFyzTceGC {
    text-align: right;
    font-weight: bold;
}
Alternatively, if Calibre intentionally does not update CSS selectors, the automatic correction should warn that changing the ID may invalidate CSS rules referring to it.

(This appears to be a different issue from the historical bug concerning ID references in the OPF spine (Calibre bug 1479462).)
quinta@ebf.cz is offline   Reply With Quote
Old 09-26-2026, 12:31 PM   #2
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 65
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
Potential issue: A straightforward modification of the selector—based on changing a specific ID—could cause unwanted formatting change in (hypothetical) other XHTML document using the same CSS and containing an (hypothetical) ID of the same name...

Therefore, the solution would have to be more complex. And probably include analyzing occurrences of IDs with the same name and, if necessary, generating new CSS definitions (rather than modifying the selector in the existing one).
quinta@ebf.cz is offline   Reply With Quote
Advert
Old Yesterday, 01:54 AM   #3
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: 46,510
Karma: 29634066
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...d838a29a1acfb8
kovidgoyal is offline   Reply With Quote
Old Yesterday, 03:29 AM   #4
quinta@ebf.cz
Connoisseur
quinta@ebf.cz began at the beginning.
 
Posts: 65
Karma: 10
Join Date: Mar 2019
Device: Kindle 3 Paperwhite
Quote:
Originally Posted by quinta@ebf.cz View Post
(...) Therefore, the solution would have to be more complex. And probably include analyzing occurrences of IDs with the same name and, if necessary, generating new CSS definitions (rather than modifying the selector in the existing one).
Or at least update all occurrences of an ID with the same name across all XHTML documents at once—like in the commit.

Thank you very much for lightning-fast response.
quinta@ebf.cz is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ordering css styling within a given class ElMiko ePub 5 08-18-2025 10:18 PM
Image styling css... what do all these properties do? ElMiko Sigil 107 06-30-2025 05:16 PM
CSS Styling based on class/existing styling 1ily Calibre 8 03-17-2025 06:37 AM
Incorrect styling with specific CSS quiris Marvin 9 07-04-2016 01:04 PM
CSS Styling not showing up in digital editions sjkramer Sigil 9 01-30-2010 10:46 AM


All times are GMT -4. The time now is 02:25 PM.


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