02-06-2016, 01:56 PM | #1 |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
[Plugin] TagMechanic
TagMechanic: conveniently remove, change the attributes of (and/or convert to different html elements) those pesky, nestable spans and divs (as well as a few others for convenience).
** NOTE: this plugin periodically checks for updated versions by connecting to github (where the source is maintained). See the end of this post for more details ** ** NOTE 2: this plugin cannot be launched when Sigil is opened via Calibre's Open With feature (or plugin of the same name) if the version of Sigil being used is less than v1.3. If you need that launch-from-calibre functionality, make sure you're running the latest version of Sigil.** This is a "rebranding" of my "Span/Div Editor" calibre-edit plugin for those who may remember and/or use it. Minimum Sigil requirement: v0.9.8 or higher Python Requirements: Python 3.4+ (Bundled or external) OS Requirements: Windows/Linux/OS X *** Linux users will have to make sure that the PyQt5 graphical python module (or PySide6 module starting with Sigil 2.0) is present if it's not already. On Debian-based flavors this can be done with "sudo apt-get install python3-pyqt5 (or pip3 install PySide6)". On Arch distributions it can be done with pacman -S python-pyqt5 and/or pacman -S pyside6 *** 1) This plugin operates on the Text files selected/highlighted in Sigil's Book Browser, so make sure you highlight the files you want to work with before launching the plugin. 2) Then choose the action you wish to perform (modify/delete), select the tag you want to perform that action on, the attribute you want to match (No attributes means you want to work with those elements that HAVE no attributes at all) and the value that that attribute should have. If the value you entered is a regular expression, check the regex box (capture groups cannot be reinserted later so they will be ignored if present). Otherwise, it is assumed that what you have entered in the New Attribute box is a literal string. 3) If you've chosen to modify a tag, you need to specify whether you want to change the tag to another tag, or change its attributes, or both. If you've chosen to change the tag to something else, then you need to enter all the attributes you want (or check the box to copy the existing attributes) otherwise the tag will be changed to the new tag with no attributes if left empty. Configuration: From the 'Edit' menu choose 'Config' to customize the plugin. In that dialog, you'll be able to change/add/remove what tags are available to change the various tags to. You can also change/add/remove things from the list of attributes to look for. They're just comma-separated lists of elements/attributes, get cute and you might break something. There's a Reset to Default button if you get in trouble. After seeing the general report of what was done (or not done), you'll have the opportunity to commit the changes, or to bail out if you get chicken. TagMechanic's code is hosted/maintained on Github. This plugin's update checker will only try to check for updates after at least 12 hours has elapsed since its last check. The plugin will only notify you about updates once for each new version released. No nagging, I promise. Changes Spoiler:
Last edited by DiapDealer; 08-03-2023 at 01:35 PM. |
02-06-2016, 04:02 PM | #2 | |
Well trained by Cats
Posts: 30,403
Karma: 58055234
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
BTW THANK YOU I have been jumping over to the Calibre editor to use the toolbag |
|
Advert | |
|
02-06-2016, 04:18 PM | #3 |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
|
02-11-2016, 10:58 AM | #4 |
Junior Member
Posts: 1
Karma: 10
Join Date: Feb 2016
Device: none
|
Commit changes
DiapDealer:
I am new to this forum, thank you for having me. I do epubs (and PDF and mobi ebooks) for a couple of small publishers, starting with indesign and/or xml files. Thanks for a VERY handy plugin. It makes cleaning up the InDesign epub mess rather a breeze. (On a separate but hopefully not too unrelated note I would be interested in hearing from any forum members about their experience with Indesign epub creation. I am finding that files that are set up with that work well for print layout really need re-tooling if the generated epub files are to be clean and well organized.) One question I had on your plugin -- my experience is that when I run the plugin the changes are made to the files even though I aborted rather than clicking commit changes. Of course I can close and elect not to save the changes from Sigil's main window, but I assumed that when the plugin offers the opportunity to abort it is the changes to the files that is being aborted...let me know if the question/comment makes no sense. Thanks again for a great forum. |
02-11-2016, 11:16 AM | #5 | |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
That's not to say I didn't make a mistake somewhere! I'll take a look. |
|
Advert | |
|
02-11-2016, 12:05 PM | #6 |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I'm definitely not experiencing what you describe on Linux or Windows. No changes are made to Sigil's files unless I click "Commit & Exit". Are you sure you didn't commit changes in a previous run of the plugin and forget?
|
02-11-2016, 12:12 PM | #7 |
Sigil Developer
Posts: 8,109
Karma: 5450184
Join Date: Nov 2009
Device: many
|
FYI:
Up until recently returning -1 was not enough for the plugin to actually abort. Only throwing an exception seemed to do the trick. That bug was fixed in Sigil-0.9.2 or Sigil-0.9.3. I don't remember which right now. So if changes still get applied, please make sure you are using the very latest Sigil-0.9.3 version. If you hit cancel and changes still get applied with that version of Sigil, Sigil itself may have a bug. KevinH |
02-11-2016, 12:15 PM | #8 | |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
EDIT: though I would still recommend users upgrading to the latest version of Sigil. This plugin needs at least Sigil v0.8.900 (bk.selected_iter()), so it's not like people stuck with 0.8.6/7 could use it anyway. There's no good reason I can think of to stay with 0.8.900 - 0.9.2. Last edited by DiapDealer; 02-11-2016 at 12:40 PM. |
|
03-10-2016, 11:12 PM | #9 |
Junior Member
Posts: 1
Karma: 10
Join Date: Feb 2015
Device: Kindle paperwhite 1st
|
Hi DiapDealer!
Thanks for your useful plugin, I very like this. I've recently got error when run this plugin. This is my error log: Code:
Status: failed Traceback (most recent call last): File "C:\Program Files\Sigil\plugin_launchers\python\launcher.py", line 135, in launch self.exitcode = target_script.run(container) File "C:\Users\username\AppData\Local\sigil-ebook\sigil\plugins\TagMechanic\plugin.py", line 545, in run guiMain(root, bk).pack(fill=tkinter_constants.BOTH) File "C:\Users\username\AppData\Local\sigil-ebook\sigil\plugins\TagMechanic\plugin.py", line 113, in __init__ self.initUI() File "C:\Users\username\AppData\Local\sigil-ebook\sigil\plugins\TagMechanic\plugin.py", line 150, in initUI self.tag_combo.current(self.gui_prefs['tag']) File "tkinter\ttk.py", line 713, in current _tkinter.TclError: Index -1 out of range Error: Index -1 out of range My machine: Windows 10 64bit, Sigil 0.9.3. I've tried remove and re-install sigil (both 0.9.3 and 0.9.2) but still get that error. EDIT: Wow, I've removed folder plugins_prefs/TagMechanic and TagMechanic can run normally. <3 Last edited by tamchec; 03-11-2016 at 03:04 AM. |
03-11-2016, 08:14 AM | #10 | |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
If you do customize the available parameters, I recommend closing the plugin and restarting it before trying to use them in a new query. Glad you got it working again (and glad you like it) |
|
09-20-2016, 07:04 PM | #11 |
Member
Posts: 16
Karma: 1422
Join Date: Mar 2016
Device: none
|
great plug-in that I missed, it solve some of my problem
|
12-02-2016, 04:10 AM | #12 |
Junior Member
Posts: 5
Karma: 10
Join Date: Nov 2016
Device: none
|
This plugin is very usefull, I have 2 request:
1 - Can you add p in the tag name list so that I dont have to delete TagMechanic.json every time I change something in p. 2 - the plugin can be used more times in the same session instead of a single process and then close? |
12-02-2016, 09:40 AM | #13 | |
Well trained by Cats
Posts: 30,403
Karma: 58055234
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
1) Many times I am doing a 'cleanup' of horrible (inline) code and it is most annoying (time consuming) to have it reload 2) I made some sort of error, so nothing got changed . Not only #1, but the terms have been cleared, giving me a second chance to mess up... Intelligent attribute suggestions Marry the Sigil Report (results will be cached when TM is first run PER BOOK to help performance. Not absolutely perfect ) results to Tag Mechanic If I select: tag name: Span whose value: Pulldown suggest the available classes found used with Spans (from the report data) |
|
12-02-2016, 10:46 AM | #14 |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
I can handle #1 (even though the need to change a "p" tag to another tag is pretty rare--and altering a p tag's attributes is already easy enough with regex).
But I'm not a fan of #2. The last-minute abort/commit feature is too important to me. And allowing multiple passes per plugin run would require me to keep track of multiple (and potentially conficting) commits to be applied (or cancelled). I won't rule it out completely, but it would take a considerable code refactoring project to accomplish it to my satisfaction. I'll have to do some cyphering on it. Also, the fact that the plugin only operates on the files that were selected before the plugin launches sort of limits what any subsequent runs could accomplish. |
12-02-2016, 11:13 AM | #15 | |
Grand Sorcerer
Posts: 27,962
Karma: 198500000
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
|
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] KindleUnpack - The Plugin | DiapDealer | Plugins | 494 | 05-18-2024 02:34 AM |
[FileType Plugin] YVES Bible Plugin | ClashTheBunny | Plugins | 27 | 01-16-2023 01:25 AM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 02:24 AM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 12:27 PM |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 12:11 PM |