View Single Post
Old 11-30-2017, 07:21 PM   #9
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,755
Karma: 24032915
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by odamizu View Post
Any suggestions on how to convert all those <p> to <h1> other than a manual edit?
Some time ago I slapped together a quick & dirty plugin that'll automatically change paragraph tags to heading tags based on NCX TOC entries.

Obviously this only works with epub2 books that have a valid (=working) NCX TOC and it works best with NCX TOC entries that reference fragment ids (e.g. file.xhtml#id2). BTW, it does the following:

1. It parses the NCX and generates a list of TOC entries.
2. If the target href has a fragment id, it'll look for the target tag based on the fragment id and change the tag (or its parent tag) to a heading tag. (=Best-case scenario.)
3. If the target href doesn't have a fragment id, it'll look for the first tag with the same text as the TOC entry.
4. If the previous step failed, it'll insert a dummy heading tag with the TOC entry as the title attribute. This is the worst-case scenario, but at least it'll allow you to generate a TOC with Sigil.

Since I only tested this plugin with a couple of old valid Calibre-generated books with working NCX TOCs but no heading tags, I don't feel comfortable releasing it, but if you want to test this beta version, PM me for a Dropbox link.
Doitsu is offline   Reply With Quote