View Single Post
Old 07-08-2020, 10:19 AM   #62
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,714
Karma: 5444398
Join Date: Nov 2009
Device: many
I really do not want to get into the middle of this as I have been tied up and have not been following this thread at all until now, but there does appear to be clear miscommunication innocently going on by all parties.

That said, please let me try to clarify things in the hope this does not degenerate further.

1. Assume you have an epub where the titles in the ncx or nav are correct and what you want.

2. Assume further that the actual headings tags in the xhtml files are either missing (they used p's) or not formatted in some sane way.


(And yes this can be a common problem with Gutenberg and some other books).

Now, the problem is if you want to regenerate the ncx or nav, using the Sigil tools because you want to later move, split, etc, you will not get back the ncx or nav entries that are there now. You will lose those "good" titles as they would be replaced during the regeneration of the ncx or nav with stuff taken from bad or missing heading tags.

So what is being asked for here, is a plugin that will parse an existing ncx or nav and extract the link back and the title text. (Actually just supporting parsing an ncx would be enough as an ncx can be autogenerated from a nav on epub3).

Then use that link to determine the destination file and in that file add a title attribute to the target heading tag that contains the title text extracted from the ncx/nav. If no target heading tag exists, then insert a new "no display" heading tag with the extracted title attribute.

If working with title attributes is too hard, then instead simply add a comment tag with the title text immediately before the destination element.

After this plugin was run then:

If the title attribute on heading tags had been set, then regenerating the ncx or nav would preserve the good titles for the most part.

If instead comments are added, then a follow-up regular expression search and replace can then be more easily done taking the title text from the just preceding comment.

That is what is being asked for here.

Hopefully, this will make everything clearer to everyone involved.

Hope this helps.

KevinH

Last edited by KevinH; 07-08-2020 at 10:56 AM.
KevinH is offline   Reply With Quote