Quote:
Originally Posted by kovidgoyal
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