![]() |
Incremental IDs plugin
3 Attachment(s)
[Plugin] AddIDs - Generates incremental ids
Updated: April 17, 2021 Current Version: "0.4.5" 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>Code:
<span class="footnote" id="id1">...</span>Version 0.4.4 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>Code:
<h1 id="idI" title="Chapter I">How it all began</h1>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.4.5.zip > OK. Version 0.4.4 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) |
Hi Doitsu,
Added this to the Sigil Plugin Index Thread. Thanks! KevinH |
Hi Doitsu,
thanks for your plugin. I've tried using it, but I get a different dialog than yours: http://s12.postimg.org/m0nq8lr2h/Sch...e_11_25_52.jpg If I click on "start" (I can't do anything else), I get this error: Code:
Status: failed(I'm using Sigil 0.9.1 on OSX 10.11.1 and I have installed Python 3.5 and beautifulsoup 4.4.1) |
Quote:
It looks like you're missing the tkinter library or parts thereof. If the OSX Sigil version has a Use Bundled Python option in the Manage Plugins dialog box, please activate it. That should take care of all library issues. If that doesn't work either, you'll probably have to install the tkinter Python library. However, before you do this, please wait for KevinH's reply; he has a Mac and will most likely be able to give you a better answer. (To exclude plugin-specific bugs, please also install another tkinter-based plugin, e.g. the epub3 output plugin. If that plugin doesn't work either, it's definitely a tkinter issue.) |
Hi,
Yes, it seems your Mac OSX python is missing pieces. If you go to the Sigil Release page you will see a Note for Mac OS users to download and install the ActiveState's ActiveTCL free community edition. Once you have that installed, please use the Manage Plugins menu and check the UseBundled Python box. That will allow Sigil to load and use tk properly. Please let me know if you run into any difficulties. KevinH |
I've installed ActiveTCL and now it's working properly. Thanks :)
|
Hi Doitsu,
FYI soup.prettify() will insert newlines around all tags even inline tags which can mess things up. That is why we added serialize_xhtml and prettyprint_xhtml to our own sigil_bs4. Thanks! KevinH |
Quote:
Code:
bk.writefile(html_id, str(soup.prettyprint_xhtml(indent_level=0, eventual_encoding="utf-8", formatter="minimal", indent_chars=" "))) |
Hi Doitsu,
By checking the launcher version dates to make sure it is at least Sigil 0.8.900 you could have it use sigil_bs4 for even for an external python 2.7 or 3.4 interpreter. Version AddIDs v0.2 does not include this code change yet, right? |
Quote:
|
Hi
I did try your plugin on an Sigil 9.2 archlinux 64 bits. As advised, I installed python-beautifulsoup4. It works nicely and is pretty useful. :thanks: I have two proposals: 1. - It worked with paragraphs. It did not work with a link tags. Could you add them to your plugin? They all have an id... 2. - Another suggestion: Would it be possible to target only one file within the EPUB (a chapter, whatever)? The same as for any regex that can be used on current file and all text files. |
Quote:
Quote:
|
Good to know. My a tags had also a class. Thanks. :thumbsup:
|
The plugin has been updated to use sigil_bs4 for pretty printing and will only process the file(s) currently selected in the Book Browser window.
Note that the plugin UI hasn't been updated, i.e., you'll need to select the file(s) that you want to process in the Book Browser window, before running the plugin. (Click the Text folder in the Book Browser window to process all files.) |
Not a snarky question at all - but why would I want to do this?
|
| All times are GMT -4. The time now is 07:09 PM. |
Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.