|  10-08-2015, 08:35 AM | #1 | 
| Grand Sorcerer            Posts: 5,763 Karma: 24088559 Join Date: Dec 2010 Device: Kindle PW2 | 
				
				Incremental IDs plugin
			 
			
			[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> Code: <span class="footnote" id="id1">...</span> <span class="footnote" id="id2">...</span> 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> 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.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) Last edited by Doitsu; 08-05-2023 at 02:26 AM. Reason: Updated for Qt 6.5.2 and Python 3.11.3 | 
|   |   | 
|  10-08-2015, 10:19 AM | #2 | 
| Sigil Developer            Posts: 9,070 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			Hi Doitsu, Added this to the Sigil Plugin Index Thread. Thanks! KevinH | 
|   |   | 
| Advert | |
|  | 
|  12-16-2015, 06:00 AM | #3 | 
| Voracious reader            Posts: 56 Karma: 14644 Join Date: Oct 2009 Device: Kobo Aura One, Sony PRS T2, iPhone 6, Cybook Orizon, Cybook Gen3 | 
			
			Hi Doitsu, thanks for your plugin. I've tried using it, but I get a different dialog than yours:  If I click on "start" (I can't do anything else), I get this error: Code: Status: failed
Traceback (most recent call last):
  File "/Applications/Sigil.app/Contents/plugin_launchers/python/launcher.py", line 134, in launch
    target_script = __import__(script_module)
  File "/Users/Sabrina/Library/Application Support/sigil-ebook/sigil/plugins/AddIDs/plugin.py", line 15, in <module>
    from tkinter import Tk, BOTH, StringVar, IntVar, BooleanVar
  File "/Applications/Sigil.app/Contents/Frameworks/Python.framework/Versions/3.4/lib/python3.4/tkinter/__init__.py", line 38, in <module>
    import _tkinter # If this fails your Python may not be configured for Tk
ImportError: dlopen(/Applications/Sigil.app/Contents/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_tkinter.so, 2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl
  Referenced from: /Applications/Sigil.app/Contents/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_tkinter.so
  Reason: image not found
Error: dlopen(/Applications/Sigil.app/Contents/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_tkinter.so, 2): Library not loaded: /Library/Frameworks/Tcl.framework/Versions/8.6/Tcl
  Referenced from: /Applications/Sigil.app/Contents/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/_tkinter.so
  Reason: image not found(I'm using Sigil 0.9.1 on OSX 10.11.1 and I have installed Python 3.5 and beautifulsoup 4.4.1) | 
|   |   | 
|  12-16-2015, 06:48 AM | #4 | |
| Grand Sorcerer            Posts: 5,763 Karma: 24088559 Join Date: Dec 2010 Device: Kindle PW2 | 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.) | |
|   |   | 
|  12-16-2015, 07:45 AM | #5 | 
| Sigil Developer            Posts: 9,070 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			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 | 
|   |   | 
| Advert | |
|  | 
|  12-17-2015, 09:26 AM | #6 | 
| Voracious reader            Posts: 56 Karma: 14644 Join Date: Oct 2009 Device: Kobo Aura One, Sony PRS T2, iPhone 6, Cybook Orizon, Cybook Gen3 | 
			
			I've installed ActiveTCL and now it's working properly. Thanks    | 
|   |   | 
|  12-17-2015, 01:58 PM | #7 | 
| Sigil Developer            Posts: 9,070 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			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 | 
|   |   | 
|  12-17-2015, 06:30 PM | #8 | |
| Grand Sorcerer            Posts: 5,763 Karma: 24088559 Join Date: Dec 2010 Device: Kindle PW2 | Quote: 
 Code: bk.writefile(html_id, str(soup.prettyprint_xhtml(indent_level=0, eventual_encoding="utf-8", formatter="minimal", indent_chars=" "))) | |
|   |   | 
|  12-17-2015, 06:39 PM | #9 | 
| Sigil Developer            Posts: 9,070 Karma: 6361556 Join Date: Nov 2009 Device: many | 
			
			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? Last edited by KevinH; 12-17-2015 at 06:43 PM. | 
|   |   | 
|  12-18-2015, 03:03 AM | #10 | 
| Grand Sorcerer            Posts: 5,763 Karma: 24088559 Join Date: Dec 2010 Device: Kindle PW2 | |
|   |   | 
|  01-18-2016, 07:36 AM | #11 | 
| Wizard            Posts: 2,625 Karma: 3120635 Join Date: Jan 2009 Device: Kindle PW3 (wifi) | 
			
			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.  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. Last edited by roger64; 01-18-2016 at 07:39 AM. | 
|   |   | 
|  01-18-2016, 07:50 AM | #12 | |
| Grand Sorcerer            Posts: 5,763 Karma: 24088559 Join Date: Dec 2010 Device: Kindle PW2 | Quote: 
 This feature will be added in the next version. It'll only process files selected in the Book Browser window. | |
|   |   | 
|  01-18-2016, 09:52 AM | #13 | 
| Wizard            Posts: 2,625 Karma: 3120635 Join Date: Jan 2009 Device: Kindle PW3 (wifi) | 
			
			Good to know. My a tags had also a class. Thanks.    Last edited by roger64; 01-18-2016 at 09:54 AM. | 
|   |   | 
|  02-02-2016, 03:30 PM | #14 | 
| Grand Sorcerer            Posts: 5,763 Karma: 24088559 Join Date: Dec 2010 Device: Kindle PW2 | 
			
			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.) | 
|   |   | 
|  08-27-2017, 10:38 AM | #15 | 
| Guru            Posts: 878 Karma: 2457540 Join Date: Nov 2011 Device: none | 
			
			Not a snarky question at all - but why would I want to do this?
		 | 
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| The new PaperWhite snuck out! Incremental update | mewmartigan | News | 192 | 09-13-2013 07:28 AM | 
| search and replace with incremental number | pimpoum | General Discussions | 4 | 07-08-2011 02:41 PM | 
| Developers, please implement an incremental update feature | usedtowork | Calibre | 7 | 03-21-2011 06:58 PM | 
| Can we at least have an incremental firmware upgrade? | mwlcarter | Kobo Reader | 2 | 05-23-2010 02:35 PM |