View Single Post
Old 06-30-2020, 09:25 PM   #25
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
Quote:
Originally posted by Mister L:
"Thanks very much, I will try this one out too. If I understand correctly, both your and Doitsu's plugins are starting from the title tags already in the files, rather than starting from the toc; while it's not the solution I'm looking for to my original problem I do think it can be useful when you are making the toc for the first time and maybe save a little bit of regex work so I'm glad to have both of them."
As I see it, there is really no need to create the TOC with the plugin because surely it's easier just to add a title attribute(with heading names) to each chapter heading which would then allow you to manually create another TOC in seconds using Generate TOC then Create TOC in Sigil.

Quote:
Originally posted by Mister L:
"If I understand correctly, both your and Doitsu's plugins are starting from the title tags already in the files"
No, my plugin does not assume a title attribute is already in the chapter headings. My plugin always creates and inserts new title attributes with chapter heading values into each chapter heading tag for each selected file. As well, it is also not necessary for the chapter heading to have an h1 tag -- it can have any tag you like -- since my plugin actually finds the chapter headings by choosing the first html line with text in it from the start of each file. As I've already mentioned, I've tried to design the plugin to accommodate and handle worst case file scenarios including files added to your epub that are a mess. So simply assuming that all your selected files will already be using an h1 tag seems a bit short sighted to me, especially if, as you say, you're dealing with either adhoc added files or you're dealing with added files that are complete trainwrecks where absolutely nothing is guaranteed and where nothing should really be expected or assumed.

Thinking about it further in regard to you creating a new TOC, it would also seem sensible to change each discovered chapter heading tag to an h1 tag since, when I tested it, Sigil's Generate TOC does not seem to recognize or find chapter headings with a 'title' attribute value. But if you changed all the chapter heading tags to h1 they will be found when you open the Generate TOC dialog in Sigil. And within Sigil's Generate TOC dialog you can re-type and change heading names, exclude headings and vary indents to your hearts content. In other words there's really no need for you to use regex or anything else to generate and create your new TOC -- you should be able to do it all easily and quickly using Sigil's Generate/Create TOC facility after running the new plugin below.

Anyway, I've modified the original plugin to also rename the html tags of all selected chapter headings to h1 in the new version of the plugin(see below), which I think will be more useful to you.

Last edited by slowsmile; 07-03-2020 at 08:14 AM.
slowsmile is offline   Reply With Quote