Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 10-08-2015, 08:35 AM   #1
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,583
Karma: 22735033
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>
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)
Attached Thumbnails
Click image for larger version

Name:	Add IDs.png
Views:	749
Size:	6.8 KB
ID:	165903  
Attached Files
File Type: zip AddIDs_v0.3.zip (107.9 KB, 1161 views)
File Type: zip AddIDs_v0.5.3.zip (126.7 KB, 220 views)

Last edited by Doitsu; 08-05-2023 at 02:26 AM. Reason: Updated for Qt 6.5.2 and Python 3.11.3
Doitsu is offline   Reply With Quote
Old 10-08-2015, 10:19 AM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,634
Karma: 5433388
Join Date: Nov 2009
Device: many
Hi Doitsu,

Added this to the Sigil Plugin Index Thread.

Thanks!

KevinH
KevinH is online now   Reply With Quote
Advert
Old 12-16-2015, 06:00 AM   #3
sbin
Voracious reader
sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.
 
sbin's Avatar
 
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
What am I doing wrong?


(I'm using Sigil 0.9.1 on OSX 10.11.1 and I have installed Python 3.5 and beautifulsoup 4.4.1)
sbin is offline   Reply With Quote
Old 12-16-2015, 06:48 AM   #4
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by sbin View Post
Hi Doitsu,
thanks for your plugin. I've tried using it, but I get a different dialog than yours:
That's the default plugin runner dialog box.

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.)
Doitsu is offline   Reply With Quote
Old 12-16-2015, 07:45 AM   #5
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,634
Karma: 5433388
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
KevinH is online now   Reply With Quote
Advert
Old 12-17-2015, 09:26 AM   #6
sbin
Voracious reader
sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.sbin is less competitive than you.
 
sbin's Avatar
 
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
sbin is offline   Reply With Quote
Old 12-17-2015, 01:58 PM   #7
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,634
Karma: 5433388
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
KevinH is online now   Reply With Quote
Old 12-17-2015, 06:30 PM   #8
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
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 for the information. If the bundled interpreter is selected, the plugin will actually use the following soup.prettyprint_xhtml() command:

Code:
bk.writefile(html_id, str(soup.prettyprint_xhtml(indent_level=0, eventual_encoding="utf-8", formatter="minimal", indent_chars="  ")))
Based on the output this seems to pretty much mimic the pretty printing that Sigil does.
Doitsu is offline   Reply With Quote
Old 12-17-2015, 06:39 PM   #9
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,634
Karma: 5433388
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.
KevinH is online now   Reply With Quote
Old 12-18-2015, 03:03 AM   #10
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
Version AddIDs v0.2 does not include this code change yet, right?
No, it doesn't. I'll look into this the next time I update the plugin.
Doitsu is offline   Reply With Quote
Old 01-18-2016, 07:36 AM   #11
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
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.
roger64 is offline   Reply With Quote
Old 01-18-2016, 07:50 AM   #12
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,583
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by roger64 View Post
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...
It works for me. If you start the plugin and enter a in the Tag box, leave everything else empty and click OK, ids will be added to all <a> tags.

Quote:
Originally Posted by roger64 View Post
2. - Another suggestion: Would it be possible to target only one file within the EPUB (a chapter, whatever)
This feature will be added in the next version. It'll only process files selected in the Book Browser window.
Doitsu is offline   Reply With Quote
Old 01-18-2016, 09:52 AM   #13
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
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.
roger64 is offline   Reply With Quote
Old 02-02-2016, 03:30 PM   #14
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,583
Karma: 22735033
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.)
Doitsu is offline   Reply With Quote
Old 08-27-2017, 10:38 AM   #15
exaltedwombat
Guru
exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.exaltedwombat ought to be getting tired of karma fortunes by now.
 
Posts: 878
Karma: 2457540
Join Date: Nov 2011
Device: none
Not a snarky question at all - but why would I want to do this?
exaltedwombat is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 11:29 AM.


MobileRead.com is a privately owned, operated and funded community.