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