Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-26-2025, 02:01 PM   #1
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
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']
That splits the file as the only 100% reliable way to have a new page (in all formats) is a new file.
Quoth is offline   Reply With Quote
Old 01-26-2025, 03:26 PM   #2
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
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.
JSWolf is offline   Reply With Quote
Advert
Old 01-26-2025, 10:34 PM   #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: 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.
kovidgoyal is offline   Reply With Quote
Old 01-27-2025, 03:43 AM   #4
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,159
Karma: 105212035
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by JSWolf View Post
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.
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.
Quoth is offline   Reply With Quote
Old 01-27-2025, 03:58 AM   #5
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,159
Karma: 105212035
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by kovidgoyal View Post
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.
I agree, a heuristic might be a bad idea. It doesn't happen often.
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
Quoth is offline   Reply With Quote
Advert
Old 01-27-2025, 05:10 AM   #6
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
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
Quote:
Originally Posted by Quoth View Post
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.
If the conversion didn't go correctly, then yes, digging in the source code is the best way to handle it.
JSWolf is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 06:42 PM.


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