View Single Post
Old 07-04-2018, 08:04 PM   #1
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: 493
Karma: 787774
Join Date: May 2013
Location: Philippines
Device: Android S5
[Plugin] ReworkChapterHeads - Add, replace and reformat chapter headings

Automatically replaces or adds selected file headings or a single selected file heading in multiple user-defined formats and styles
Requirements
Plugin Type: Edit
MIT Licence(OSI)
Minimum Sigil requirement: v0.9.3 or higher
Python Requirements: Python 3.4+ (Bundled or External)
OS Requirements: Windows, OSX or Linux
*** Tested on Windows 7, 8 & 10, OSX and Linux ***
Current Version: "0.2.2"

Installation
* Select Manage Plugins from the Plugins menu. In the dialog box, select either the Bundled Python or the External Python(Python 3.4+ should be installed on your computer to run this plugin externally).

* Click Add Plugin and select ReworkChapterHeads_vXXX.zip. This will load and install the plugin into Sigil, which you can then select and run using Plugins > Edit > ReworkChapterHeads

Description
This plugin tries to provide an easy and quick way of replacing or adding either multi-file headings or a single file heading in your epub 2 or epub 3 file(added in v0.2.2.) that will be formatted according to the user's own individual styling preferences. The plugin allows the user to do the following:

* Remove and/or add heading(s)
* Add or change the heading text name
* Add or change heading styles
* Change the heading number style to numeric string, number as text or roman numerals
* Change the heading number case to titlecase, uppercase or lowercase
* Add classes to heading tag(s)
* Create numbered headings only
* Hide heading(s)

This plugin automatically inserts all selected file group number types consecutively in various user-defined formats and styles using normal file selection from Sigil's Book Browser(See Plugin Run for details).

User Options 1 -- Remove heading(s) (via dialog)

* Remove heading(s) formatted with...
This option allows the user to initially select and remove all selected heading lines in the epub or a single selected single heading line that is formatted in h1 to h6 heading style. If the Remove button is pressed the appropriate heading lines from the selected files will all be removed. But if the Skip button is pressed then this dialog will do nothing and the plugin will continue. So if you are replacing your heading(s) you should select the relevant heading style and use the Remove button but if you are adding new heading(s) then you should just use the Skip button(no headings will be removed). This remove/add feature is quite flexible and can also be used in other ways e.g. like removing the current h1 chapter headings in an epub and perhaps replacing them with formatted and styled h2 chapter headings.

User Options 2 -- Add new heading(s)(via dialog)

* Add heading name template
This option allows the user to type and add the heading name part of the new heading into the textbox either in title case, lower case or upper case i.e. whatever you type into the textbox will be used as the main heading name throughout.

* Select heading style
Now allows a choice of h1 to h6 heading style for all newly generated headings(changed in v0.1.6).

* Select chapter number style
Allows the user to select the chapter or part numbering style e.g. numeric string, number as text or roman numerals.

* Select chapter number case
This option only works if you have previously chosen Select chapter number style > Number as Text. Available user choices: titlecase, uppercase or lowercase. Chapter number as text case examples: one, Ten and TWENTY-THREE.

* Add classes to heading tag(s)
The user just types a class name into the textbox for that class to be included in all the newly generated chapter heading tags. Also make sure that the class has already been properly defined in the css. If you need to add more than one class per chapter heading, then just add in each class separated by a comma or a space.

* Use numbered headings only(added in v0.1.4)
Allows the user to just use numbered headings for all chapter or part headings e.g. 1, 2, 3 or ONE, TWO, THREE or I, II, III. If Number as Text is selected, the text will always display in upper case whenever numbered headings is selected.

* Hide heading(s)
This feature is particularly useful if you are using jpeg images as chapter headings throughout your epub. By selecting and tagging the same pages containing these heading images using this plugin feature, these new chapter headings will remain invisible in Text View but they will still be present in HTML View, so this should help to make those chapter heading images both linkable and searchable in your epub.

Caveat
The new maximum number of chapters allowed when using the Number as Text or Roman Numerals dialog options has been increased to 100 (added in v0.1.7). Otherwise you'll get overrun errors.

Depending on whether you use h1 to h6 heading styles, be sure that the chosen heading style for your heading is already properly defined by you in the css, otherwise the default heading style will be used. This plugin does not add or change styling in the css.

Plugin Run

* Using Ctl-Click and Shift-Click with your mouse, select either a single file or a multi-file group from Sigil's Book Browser.

* Then just run the plugin and the chapter heading(s) will automatically be replaced or added and formatted according to your dialog choices.

* Also bear in mind, for all chapter file group selections, that this plugin does not automatically update the epub TOC file or the Logical TOC(toc.ncx) to your new chapter heading style, so you should perhaps also run Create TOC and Generate TOC in Sigil to match up all ebook/device displays after running this plugin.

This plugin can now add, replace or modify both selected file groups as well as modify a single heading from a selected xhtml file(added in v0.1.6).

Plugin users should now be able to use single file selection to add or replace the main heading from any selected epub xhtml file e.g. any chapter heading, TOC file, Title, Introduction, Preface, About the Author etc.


Changes

Spoiler:

v0.2.2
-- Removed epub 2 validation. This plugin will now work with epub 2 or epub 3 files. Thanks to @lumpynose.
v0.2.1
-- Fixed a minor bug in the epub validation routine.
v0.2.0
-- Converted User Options 2 dialog from a single column to two column display to prevent widget crossover problems occurring when Windows Accessibility options are used. Thanks to Thasaidon.
v0.1.9
-- Fixed a bug concerning the Add numbered heading only option where the chapter heading text was also being wrongly displayed with the chapter number. Thanks to BeckyEBook.
v0.1.8
-- In the dialog, the text typed into the Add heading name template textbox will now always be saved and displayed on the next plugin run. Thanks to BeckEBook.
-- Fixed a problem in the version updater, which wasn't working.
V0.1.7
-- The new maximum number of chapters allowed when using the Number as Text or Roman Numerals dialog options has been increased to 100.
v0.1.6
-- Plugin functionality has been extended with the following added features:
* Users can now use the plugin to modify a single selected file heading.
* The heading styles available have been increased to h1 to h6 to help accommodate the change.
* Added various cosmetic/notification enhancements to the dialogs to aid ease of use.
v0.1.5
-- The user will now be able to select h1, h2 and h3 heading styles from both dialogs.
v0.1.4
-- Added a new dialog option that allows the user to select numbered headings only. Examples: 1,2,3 or ONE, TWO, THREE or I, II, III.
v0.1.3
-- The plugin will now automatically save the last settings from both dialogs as default settings.
v0.1.2
-- Fixed a bug with roman numerals formatting which was caused by a mispelling by me.
v0.1.1
-- Switched to using ComboBoxes in all dialogs for better visibility.
v0.1.0
-- Initial release
Attached Thumbnails
Click image for larger version

Name:	Remove_Headings.JPG
Views:	450
Size:	23.7 KB
ID:	164951   Click image for larger version

Name:	Single_File_Selection.jpg
Views:	490
Size:	37.7 KB
ID:	164952   Click image for larger version

Name:	File_Group_Selection.jpg
Views:	408
Size:	37.4 KB
ID:	164953  
Attached Files
File Type: zip ReworkChapterHeads_v022.zip (79.2 KB, 212 views)

Last edited by slowsmile; 07-13-2019 at 12:09 AM.
slowsmile is offline   Reply With Quote