[Plugin] AddIDs - Generates incremental ids
Updated: August 8, 2023
Current Version: "0.5.3"
Note: Starting with version 0.3, the plugin will no longer automatically process all files. You'll need to select the file(s) to be processed in the Book View browser, or click the Text folder to process all .xhtml files.
This very simple
beautifulsoup4 based plugin can be used to add incremental ids to specific tags. You can either select all tags of a specific type or only tags with specific attributes
and values. (If you specify an attribute, you'll also need to specify a value.)
For example, if you only enter
p in the
Tag box and click OK, the plugin will add incremental IDs to all paragraph tags in the .xhtml file currently selected in the Book Browser window (or all .xhtml files, if the Text folder is selected).
If you enter
span,
class and
footnote, the plugin will add incremental IDs only to span tags that have a footnote class attribute.
For example,
Code:
<span class="footnote">...</span>
<span class="footnote">...</span>
will be changed to:
Code:
<span class="footnote" id="id1">...</span>
<span class="footnote" id="id2">...</span>
If you also select the Use Roman numerals option, the plugin will convert the counter value to upper-case Roman numerals. Since the Roman numerals converter can only handle numbers from 1 to 3999, this option should only be used for heading tags, page numbers etc. You also may want to clear the
ID: value, since Roman numerals are by default valid IDs without a letter prefix. (Regular IDs need to be prefixed by at least one letter.)
Version 0.5.1 also allows you to add title attributes with consecutive numbers. For example, if you enter h1 as the tag, Chapter as the title prefix and check both check-boxes, h1 tags will be changed from:
Code:
<h1>How it all began</h1>
to:
Code:
<h1 id="idI" title="Chapter I">How it all began</h1>
(This feature allows you to update the TOC without changing the actual chapter headings since h1-h6 title attributes take precedence over h1-h6 tag contents when the TOC is generated.)
Installation:
If you're using Sigil 0.8.7 (or an older version), you'll need to install either
Python 2.7 or Python 3.4 and beautifulsoup4. (Otherwise select the Use Bundled Python option.)
To install the plugin open Sigil and select:
Plugins > Manage Plugins > Add Plugin > AddIDs_0.5.3.zip > OK.
Version 0.5.0 requires Sigil 0.9.8 or higher. If you have an older Sigil version, you'll need to download version 0.3.0.
Usage:
To run the plugin select:
Plugins > Edit > AddIDs.
License: GNU General Public License v3 (GPL-3)