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 02-06-2016, 01:56 PM   #1
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
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:
v0.4.1
- Port from calibre/Qt to Sigil/Tkinter
v0.4.2
- Add 'p' tag to default list of tags the plugin can operate on
v0.4.3
- Skip problematic icon assignment on OS X
v0.4.4
- Made plugin code easier to maintain
- Made config widget dynamically multi-column
v0.4.5
- Added ability to tweak font-sizes
v0.5.0
- Converted the plugin's UI to PyQt5 to mirror Sigil's
v0.5.1
- Fix to work with (stand alone) versions of Sigil[ less than v1.3.0
v0.5.2
- Add PL Translations (thanks @BeckyEbook)
- Various other cosmetic and logical tweaks by @BeckyEbook
- fix reports being output with no linebreaks
v0.6.0
- Overhaul to work with current PyQt5 and future PySide6
v0.6.1
- work with pre-1.6 versions of Sigil
v0.6.2
- More backward compatibility fixes
v0.6.3
- Fix to work with Qt6.5.2 and Python 3.11.3 for Sigil 2.0
- Update to latest upstream plugin_utils.py
Attached Files
File Type: zip TagMechanic_v0.6.3.zip (28.9 KB, 484 views)

Last edited by DiapDealer; 08-03-2023 at 01:35 PM.
DiapDealer is offline   Reply With Quote
Old 02-06-2016, 04:02 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,781
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by DiapDealer View Post

1) This plugin operates on the Text files selected/highlighted in Sigil's Book View, so make sure you highlight the files you want to work with before launching the plugin.
Don't you mean Book Browser

BTW
THANK YOU

I have been jumping over to the Calibre editor to use the toolbag
theducks is online now   Reply With Quote
Old 02-06-2016, 04:18 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by theducks View Post
Don't you mean Book Browser
Sure do. Thanks!

Quote:
Originally Posted by theducks View Post
BTW
THANK YOU

I have been jumping over to the Calibre editor to use the toolbag
And you're welcome.
DiapDealer is offline   Reply With Quote
Old 02-11-2016, 10:58 AM   #4
IHS
Junior Member
IHS began at the beginning.
 
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.
IHS is offline   Reply With Quote
Old 02-11-2016, 11:16 AM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by IHS View Post
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.
I'll certainly look into it, but it's definitely aborting the changes when I use it on my systems (or it was at one point anyway). The changes wrought by any plugin should never be committed to Sigil's working copy until the plugin safely returns a value of zero. Abort returns a value of -1.

That's not to say I didn't make a mistake somewhere! I'll take a look.
DiapDealer is offline   Reply With Quote
Old 02-11-2016, 12:05 PM   #6
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by DiapDealer View Post
That's not to say I didn't make a mistake somewhere! I'll take a look.
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?
DiapDealer is offline   Reply With Quote
Old 02-11-2016, 12:12 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,633
Karma: 5433388
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
KevinH is offline   Reply With Quote
Old 02-11-2016, 12:15 PM   #8
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by KevinH View Post
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
Ahh... I'd forgotten about that. Perhaps I'll make a version that throws an exception just to be sure. Thanks for reminding me.

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.
DiapDealer is offline   Reply With Quote
Old 03-10-2016, 11:12 PM   #9
tamchec
Junior Member
tamchec began at the beginning.
 
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
Please tell me how to fix. Thanks.
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.
tamchec is offline   Reply With Quote
Old 03-11-2016, 08:14 AM   #10
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by tamchec View Post
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:


Please tell me how to fix. Thanks.
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
If you modified the attributes or change-to elements from the default, it's possible that things can get a bit out of sync. I tried to include some basic error checking when customizing the plugin, but I'm quite certain that it doesn't cover all the ways it might possibly get broken. If the plugin still runs, you can use the "Reset to default" button to get back to a fresh install, but if the plugin doesn't run, deleting the json preference file (as you've discovered) will do the same thing.

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)
DiapDealer is offline   Reply With Quote
Old 09-20-2016, 07:04 PM   #11
Auramazda
Member
Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.Auramazda is no ebook tyro.
 
Posts: 16
Karma: 1422
Join Date: Mar 2016
Device: none
great plug-in that I missed, it solve some of my problem
Auramazda is offline   Reply With Quote
Old 12-02-2016, 04:10 AM   #12
Crick
Junior Member
Crick began at the beginning.
 
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?
Crick is offline   Reply With Quote
Old 12-02-2016, 09:40 AM   #13
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,781
Karma: 54830978
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by Crick View Post
This plugin is very usefull, I have 2 request:

2 - the plugin can be used more times in the same session instead of a single process and then close?
I second this.
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)
theducks is online now   Reply With Quote
Old 12-02-2016, 10:46 AM   #14
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
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.
DiapDealer is offline   Reply With Quote
Old 12-02-2016, 11:13 AM   #15
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 27,546
Karma: 193191846
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by theducks View Post
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)
The plugin framework has no interface to Sigil's report data. That would take changes to the plugin framework--and to Sigil itself to accomplish. Not entirely out of the question, but not very likely--at least not for a single plugin. There'd have to be a need for multiple plugins (and an interest from other plugin devs) to justify that kind of expansion of the framework.
DiapDealer is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FileType Plugin] YVES Bible Plugin ClashTheBunny Plugins 27 01-16-2023 01:25 AM
[GUI Plugin] KindleUnpack - The Plugin DiapDealer Plugins 492 10-25-2022 08:13 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


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


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