I've also had a go at trying to create a plugin for your problem. I doubt whether it will satisfy all your requirements but it might be useful to you.
For this plugin I've tried to imagine worst case scenarios where you either have bad formatting or you have to split an ebook or you have to add some files in Sigil.
This plugin only deals with the main chapter headings for each file that you select in Sigil's Book Browser. It does not deal with h2, h3, h4 etc. That's really up to you. It also doesn't matter what tag is used on the chapter heading in the file because the plugin will always attempt to find the topmost line containing text in every file(which, fingers crossed, should be the main heading). Thus the topmost line with text in any selected file is assumed to be the chapter heading for that file.
With regard to 'proper' title case, I've also included a JSON file which has already been pre-populated to allow certain words to be in lower case like ''of', 'from', 'by', 'to' etc in the title attribute. The JSON file only contains one item -- called 'ignore-titlecase' which contains a space delimited string. You can also add your own words to this string to avoid title case and keep lower case so that you can more easily control title case outcomes in the 'title' attributes for the headings.
To use the plugin you must first click and select all the files in the Book Browser that you want processed by the plugin. You can also use Shift-Click to select a group of files. Then just run the plugin and the title attribute with current heading name will be added to the topmost html tag for each selected file.
Also note that this plugin will not work well if fake smallcaps are used in the headings. See link below:
[Original Plugin has been removed] -- see updated plugin in my post below
Last edited by slowsmile; 07-01-2020 at 07:53 AM.
|