![]() |
#1 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,159
Karma: 105212035
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Snag if class="chapter"
Occasionally I convert an azw3 or epub and on viewing each paragraph is a new page.
It's caused by the person/program doing original formatting choosing to name the regular body style paragraph <p class="chapter">some stuff</p> Just use Calibre editor to rename the class to something like "p-indent" Is there a way in any of the default conversion settings to detect this and automatically rename the class? The default Structure detection is normally useful Detect chapters at (X-Path expression) Code:
//*[((name()='h1' or name()='h2') and re:test(., '\s*((chapter|book|section|part)\s+)|((prolog|prologue|epilogue)(\s+|$))', 'i')) or @class = 'chapter'] |
![]() |
![]() |
![]() |
#2 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,796
Karma: 146391129
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
What I do sometimes is remove the x-path, do the conversion, and put the x-path back. That works without having to change any of the code.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,382
Karma: 27756918
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Well one could come up with some kind of heuristic for it I suppose. Maybe if there are consecutive runs of paragraphs in a single HTML file with that class or something. I generally like to avoid heuristics though as they can occasionally have false positives and lead to strange behavior.
|
![]() |
![]() |
![]() |
#4 |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,159
Karma: 105212035
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Yes, I've done that too. Though when a conversion produces madly unexpected results I look in the editor and then it's trivial to change.
|
![]() |
![]() |
![]() |
#5 | |
Still reading
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 14,159
Karma: 105212035
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
|
Quote:
I just wondered was there a way in existing "Look & feel" to automatically replace class="chapter" with class="p-body" that occurs in ANY <div> or <p> tag, and rename the CSS too. I've seen a couple of mad ebooks with no <p> tags at all. They used <div> instead. Obviously it would be very broken if the CSS wasn't changed. Also class="p-body" might exist, so that's a bad choice. One would need a reliable new unique class name. However I've also seen the chapters or other headings use <p> and you'd want to detect Chapter there. Calibre actually uses <p> instead of <h> on docx conversion unless the default names heading1 etc used. But it's common to have different styles of heading at same level so the default generic style names can't be used. I use the Span & Div edit tool to replace <p> with <h2> where there is the class that is obviously a Heading style. Then for some styles I have to add normal to the CSS as H styles are automatically bold and some fonts used for headings are already heavy/bold and then look garbage if bold applied |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,796
Karma: 146391129
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
"class="calibre"" in the <html header line? | retiredbiker | Conversion | 11 | 06-21-2023 01:25 PM |
Alternative to "class=chapter" to force a page break | porphyry5 | Conversion | 6 | 01-27-2022 06:10 PM |
Apple's Books/iBooks: "in this chapter" "in this book" display | Hitch | ePub | 9 | 06-25-2020 09:30 PM |
Class action: "sale" royalties on "licensed" ebooks | drjenkins | News | 2 | 06-02-2016 08:44 AM |