View Single Post
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,588
Karma: 108669873
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