08-13-2020, 01:14 AM | #1 |
Enthusiast
Posts: 38
Karma: 467802
Join Date: Apr 2016
Device: none
|
[Plugin] cssUndefinedClasses
Hi to all,
as requested some weeks ago, here is a plugin that deletes from the xhtml all classes and ids that are not referenced anywhere in the stylesheets (nor in fragment identifiers in href or other attributes, in the case of ids). There is a graphical interface that lets the user choose what they want to remove and what they want to keep. I tried to adjust the colors of backgrounds and texts to keep it all readable and not too ugly in the various dark modes, but I couldn't test the plugin on a Mac (and I know Tcl/Tk and Mac don't always get along very well...). The parser css used by the plugin is css_parser/cssutils, the parser xhtml is gumbo (adapter for sigil_bs4), all provided by Sigil installers. For now I tested the plugin with Sigil 1.2 and 1.3 on Linux Mint, Manjaro, Win7 and Win10. I uploaded the first version of the plugin as a beta (needs some more testing), let me know if you encounter any problems, thanks! The license of the plugin is the GPL v3 or any later version. Changes: Spoiler:
Last edited by wrCisco; 08-22-2020 at 02:01 PM. Reason: Update to version 0.2.2 |
08-13-2020, 02:44 AM | #2 |
just an egg
Posts: 1,693
Karma: 5514284
Join Date: Mar 2015
Device: Kindle, iOS
|
I use Calibre to do this and am happy to now have this functionality in Sigil. (I also love your cssRemoveUnusedSelectors plugin )
|
08-13-2020, 10:02 AM | #3 |
Sigil Developer
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
|
Thank you! I added it to the Sigil Plugin Index.
|
08-14-2020, 03:47 PM | #4 | |
Enthusiast
Posts: 38
Karma: 467802
Join Date: Apr 2016
Device: none
|
Quote:
|
|
08-14-2020, 03:53 PM | #5 |
Enthusiast
Posts: 48
Karma: 10000
Join Date: Apr 2011
Device: iPad
|
Ah! Nice. I too have either resorted to sloppy Regex or Calibre to take care of this. Thanks!
|
08-22-2020, 02:15 PM | #6 | |
Enthusiast
Posts: 38
Karma: 467802
Join Date: Apr 2016
Device: none
|
Quote:
I just uploaded version 0.2.2 of the plugin, with an icon for displaying in Sigil and in the window manager (if the 'manager' allows it). Also, the plugin now accepts some invalid class and id names found in css selectors (even if they are invalid, the plugin should not ignore them entirely). |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Metadata Source Plugin] Empty Plugin? (Fake Identifier) | mneimeyer | Plugins | 3 | 11-11-2019 09:07 PM |
[Plugin] QuickPrefsEdit - Edit plugin prefs json files. | slowsmile | Plugins | 3 | 07-25-2018 09:14 PM |
Goodread Perception Expander plugin not shown on plugin list (kobo h2o) | www | KOReader | 4 | 09-28-2017 11:34 AM |
Problem with my ScrambleEbook plugin and the Plugin Updater tool | jackie_w | Development | 14 | 01-19-2017 11:49 PM |
Plugin not customizable: Plugin: HTML Output does not need customization | flyingfoxlee | Conversion | 2 | 02-24-2012 03:24 AM |