View Single Post
Old 11-14-2017, 11:14 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: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
[Plugin] LogicalTOCStyler

Changes the styling of the Logical TOC(Device TOC)

Requirements
Plugin Type: Edit
MIT(OSI) Licence
Minimum Sigil requirement: v0.9.3 or higher
Python Requirements: Python 3.4+ (Bundled or External)
OS Requirements: Windows, Linux or OSX
*** Tested on Windows 7, 8 & 10 only ***
Current Version: "0.1.1"

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 LogicalTOCStyler _vXXX.zip. This will load and install the plugin into Sigil, which you can then select and run the plugin by selecting Plugins > Edit > LogicalTOCStyler

Description
This plugin allows the user to quickly and safely re-style the Logical TOC in titlecase/uppercase without the user going near the toc.ncx file. This simple plugin just reformats the Logical TOC according to the needs of the plugin user.

This plugin will also convert to proper titlecase headings in the toc.ncx file. This means that words like "and", "the", "in", "on", "from" etc. will remain in lower case in all titlecased headings after conversion. See titlecase_exclude_list in Using Preferences for more details.(added in v0.1.1)

User Options(via dialog)

* Convert all headings to titlecase

* Convert all headings to uppercase

* Convert only chapter headings to uppercase

* Convert only user-defined headings to uppercase (set in plugin prefs -- see Using Preferences)

* Default prefs reset -- Resets the user-defined heading list back to the original default list.

Using Preferences
You can use prefs for this plugin in Sigil by going to Plugins > Manage Plugins > Open Preferences Location > plugin_prefs > LogicalTOCStyler > LogicalTOCStyler.json.

user_defined_search_list
The default user-defined settings in the json file are shown below:

user_defined_search_list: [
"preface",
"introduction",
"foreword",
"epigraph",
"prologue",
"chapter",
"epilogue",
"Index"
]

The user can add or remove headings to and from this search list as preferred. Additional headings should always be added in lowercase. If any of the above headings in the heading list are found in your Logical TOC then they will be formatted in uppercase. Any headings not included in the search list will all be formatted in titlecase.

titlecase_exclude_list(added in v0.1.1)
This is a default list of words like "and", "in", "on", "from" etc(in plugin prefs) that will always remain in lowercase whenever headings are titlecased. Users can also add or remove words to or from this list as they prefer in order to ensure that "proper" titlecase is implemented for all headings in the Logical TOC. So if you want a word excluded from titlecase that isn't already in the default list -- then you can just add it to this list(in lowercase) in plugin prefs and it will stay in lowercase. The default list in plugin prefs is shown here:

"titlecase_exclude_list": [
"the",
"a",
"an",
"at",
"of",
"with",
"to",
"and",
"on",
"by",
"for",
"in",
"from"
]

Plugin Run
First load your epub into Sigil and then just run this plugin. Users can also run this plugin multiple times on the same epub if they want. After running this plugin users can then easily check and verify the new heading format within the toc.ncx file using html view.

Changes;
Spoiler:

v0.1.0
-- Initial Release
v0.1.1
-- Proper titlecase has been implemented(See Using Preferences). Thanks to AlanHK.
-- Fixed apostrophe problem.
Attached Files
File Type: zip LogicalTOCStyler_v011.zip (26.2 KB, 1680 views)

Last edited by slowsmile; 01-10-2018 at 11:16 PM.
slowsmile is offline   Reply With Quote