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 08-13-2020, 12:14 AM   #1
wrCisco
Enthusiast
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 41
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.

The license of the plugin is the GPL v3 or any later version.

I tested this plugin on Windows 11 with Sigil 2.3 and 2.4.2, but it should work the same on Linux and macOS.
If the plugin's window doesn't appear after launch on macOS, it probably is just hidden behind other windows: you should be able to bring it to the foreground just by clicking on the plugin's icon in the dock.

Until version 0.2.2 the plugin by default looked for id references in the form of fragment identifiers in the attributes "href", "epub:textref" and "src", since version 0.2.3 this list has been expanded in three groups of attributes (users can edit these lists in the Preferences pane of the plugin, after launching it).

Attributes that can contain a fragment identifier:
  • href
  • epub:textref
  • src
  • action
  • cite
  • data
  • form
  • formaction
  • ping
  • poster
  • xlink:href
  • altimg
  • cdgroup
  • resource

Attributes that can contain a single id reference:
  • commandfor
  • list
  • popovertarget
  • xref
  • aria-activedescendant

Attributes that can contain a whitespace separated list of id references:
  • for
  • headers
  • itemref
  • aria-controls
  • aria-describedby
  • aria-details
  • aria-errormessage
  • aria-flowto
  • aria-labelledby
  • aria-owns

(A fragment identifier is the part of a URI that follows the '#' character, e.g. href="#fragid".
An id reference is just the value of the id that is referenced.)

Some of the attributes will probably never be used in epubs to match an element's id (like the "ping" attribute), but it should be harmless to keep them around, just in case.

Version 0.2.3 of the plugin also provides a different tk theme for the Linux ui, that I find more pleasant than the default one. If it causes problems, you can disable it updating manually the preferences of the plugin in $SIGIL_PREFS/plugin_prefs/cssUndefinedClasses/cssUndefinedClasses.json, setting (or adding) the "tktheme" entry to an empty string (i.e.
Code:
"tktheme": "",
).

Changes:
Spoiler:
v0.2.0:
- the search for fragment identifiers has been extended to all xml files (ncx, media overlays...);
- the list of attributes in which to search for fragment identifiers is user customizable in the preferences pane, and the default values are href, epub:textref and src;
- another option for the user in the preferences pane is to restrict the search for classes and IDs to be removed to only a selected subset of files.
v0.2.1:
- flash bug fix (in v0.2.0 fragment identifiers were searched for only in selected xhtml files).
v0.2.2
- added an icon for the plugin;
- less rigid parsing of css selectors: now the plugin process also some invalid names for classes and ids in the stylesheets (although invalid, the plugin shouldn't ignore them).
v0.2.3
- expanded the list of attributes used to search for id references;
- added the clearlooks tk theme for Linux ui
Attached Files
File Type: zip cssUndefinedClasses_v0.2.2.zip (26.0 KB, 2462 views)
File Type: zip cssUndefinedClasses_v0.2.3.zip (69.9 KB, 142 views)

Last edited by wrCisco; 02-25-2025 at 11:49 AM. Reason: Update to version 0.2.3
wrCisco is offline   Reply With Quote
Old 08-13-2020, 01:44 AM   #2
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,787
Karma: 6706327
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 )
odamizu is offline   Reply With Quote
Advert
Old 08-13-2020, 09:02 AM   #3
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: 8,437
Karma: 5702578
Join Date: Nov 2009
Device: many
Thank you! I added it to the Sigil Plugin Index.
KevinH is offline   Reply With Quote
Old 08-14-2020, 02:47 PM   #4
wrCisco
Enthusiast
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 41
Karma: 467802
Join Date: Apr 2016
Device: none
Quote:
Originally Posted by odamizu View Post
I use Calibre to do this and am happy to now have this functionality in Sigil. (I also love your cssRemoveUnusedSelectors plugin )
Quote:
Originally Posted by KevinH View Post
Thank you! I added it to the Sigil Plugin Index.
Thanks for the appreciation. I just uploaded a second version of the plugin with some improvement and a preferences panel for the user.
wrCisco is offline   Reply With Quote
Old 08-14-2020, 02:53 PM   #5
David Kudler
Enthusiast
David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'David Kudler knows the difference between 'who' and 'whom'
 
David Kudler's Avatar
 
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!
David Kudler is offline   Reply With Quote
Advert
Old 08-22-2020, 01:15 PM   #6
wrCisco
Enthusiast
wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.wrCisco ought to be getting tired of karma fortunes by now.
 
Posts: 41
Karma: 467802
Join Date: Apr 2016
Device: none
Quote:
Originally Posted by David Kudler View Post
Ah! Nice. I too have either resorted to sloppy Regex or Calibre to take care of this. Thanks!
I'm glad it helps.


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).
wrCisco is offline   Reply With Quote
Old 12-21-2024, 04:13 PM   #7
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,787
Karma: 6706327
Join Date: Mar 2015
Device: Kindle, iOS
Hello! After updating macOS from Sonoma to Sequoia 15.2, cssUndefinedClasses plugin stopped working. The plugin launches and starts running ... and running ... and running ... and never gets past the startup window to completion (I let it run 30 minutes, also tried it on multiple ebooks).

Click image for larger version

Name:	Screenshot.png
Views:	85
Size:	26.9 KB
ID:	212590

The same thing is happening with cssRemoveUnusedSelectors plugin.

I'm guessing there's some incompatibility introduced in Sequoia. Maybe something with Python ...?

Click image for larger version

Name:	screenshot3.png
Views:	94
Size:	70.0 KB
ID:	212592

What further information can I provide to help identify the problem and solution?

Thank you

ETA: I do have "Use Bundled Python" checked in the Manage Plugins window and all other plugins I have tried work. It's just these two.

Last edited by odamizu; 12-21-2024 at 04:30 PM.
odamizu is offline   Reply With Quote
Old 12-21-2024, 05:13 PM   #8
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: 8,437
Karma: 5702578
Join Date: Nov 2009
Device: many
That is the plugin icon. This plugin uses Tk for graphics. My guess is Tk is either broken by Sequoia or the plugin's Tk window has opened underneath Sigil, or underneath the PluginRunner dialog or requires you to click on the plugins icon to bring its dialog window to the front.

This is why I never use the latest release of macOS as it invariably breaks things. I stay one full macOS version back.

Last edited by KevinH; 12-21-2024 at 10:00 PM.
KevinH is offline   Reply With Quote
Old 12-22-2024, 12:53 AM   #9
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,787
Karma: 6706327
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by KevinH View Post
That is the plugin icon. This plugin uses Tk for graphics. My guess is Tk is either broken by Sequoia or the plugin's Tk window has opened underneath Sigil, or underneath the PluginRunner dialog or requires you to click on the plugins icon to bring its dialog window to the front.
Clicking on the plugin dock icon worked! As soon as I did that, the plugin window appeared and all was well again. Thank you!

Quote:
This is why I never use the latest release of macOS as it invariably breaks things. I stay one full macOS version back.
I usually delay updating, and in this case I waited for 15.2 (rather than updating with 15.0), but I wanted the new iPhone mirroring function, so I took the plunge.

Also, if I had waited until next fall to update to Sequoia (staying one full macOS version behind), would this necessarily have been fixed by then? (and how would it have been fixed if someone didn't discover the problem?)
odamizu is offline   Reply With Quote
Old 12-22-2024, 01:59 AM   #10
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 44,466
Karma: 167726775
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by odamizu View Post
Also, if I had waited until next fall to update to Sequoia (staying one full macOS version behind), would this necessarily have been fixed by then? (and how would it have been fixed if someone didn't discover the problem?)
Very likely one of the developers, likely KevinH since he is a Mac user, would update a test machine. There are users who update to the "latest and greatest" and then kvetch when things break. Personally, I keep testing Sigil on my Windows 11 Preview virtual machine so I can attempt to spot any issues with Sigil in that environment before the updates arrive for my physical computer.
DNSB is offline   Reply With Quote
Old 12-22-2024, 11:49 AM   #11
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: 8,437
Karma: 5702578
Join Date: Nov 2009
Device: many
I think this is not a bug but a new "security feature" of Sequoia which forces the user to select the icon of forked/subprocess gui programs (like a plugin using Tk for example) at least the very first time something is launched.

MacOS ideas of "security" are for the birds as any python program can pretty much do whatever it wants to files it has permission to access.
KevinH is offline   Reply With Quote
Old 12-22-2024, 05:04 PM   #12
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,787
Karma: 6706327
Join Date: Mar 2015
Device: Kindle, iOS
Quote:
Originally Posted by DNSB View Post
Very likely one of the developers, likely KevinH since he is a Mac user, would update a test machine. There are users who update to the "latest and greatest" and then kvetch when things break. Personally, I keep testing Sigil on my Windows 11 Preview virtual machine so I can attempt to spot any issues with Sigil in that environment before the updates arrive for my physical computer.
I see. So having been so reckless as to update to the latest macOS 3 months after release (instead of waiting a full year), I should not report issues (which constitutes kvetching?) but instead wait for the developers to update a test machine (next fall) and discover the issue on their own? Because to do otherwise constitutes unwanted kvetching? Really?
odamizu is offline   Reply With Quote
Old 12-22-2024, 05:29 PM   #13
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: 8,437
Karma: 5702578
Join Date: Nov 2009
Device: many
No. I only meant that updating to Sequoia that has been out officially only 2 months is probably not something for everyone.

FWIW, I could already both extend and mirror my screen to my iPad and iPhone using the earlier version of macOS, but to each his own.

Testing and reporting issues is always fine. Thank you.

It is just that early releases of macOS are often very broken and do not get fixed by Apple until many minor releases have come and gone.

If you read my earlier reply, I think this is an extra "security" change by Apple. It is really Qt that vets its software against Apple releases and trues to make sure gui things work.

There have already been two MacOS releases that crashed for no reasons which we had to track down and work around in Sigil only to undo those changes when Apple and or fixed its issues. You helped test workarounds for both of them.

Last edited by KevinH; 12-22-2024 at 05:34 PM.
KevinH is offline   Reply With Quote
Old 12-22-2024, 05:54 PM   #14
odamizu
just an egg
odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.odamizu ought to be getting tired of karma fortunes by now.
 
odamizu's Avatar
 
Posts: 1,787
Karma: 6706327
Join Date: Mar 2015
Device: Kindle, iOS
My reply was really in response to DNSB's comment about "kvetching", which startled me as you (KevinH) have always seemed interested in hearing about issues, even from reckless early adopters (which I usually am not — I clung to High Sierra for years and years).

In any case, I now have a simple and effective workaround, for which I thank you.

P.S. The new feature in Sequoia that interested me is that I can now control my iPhone from my Mac. I think this is new and different from being able to mirror a Mac to an iPhone/iPad. It requires macOS Sequoia and iOS 18: https://support.apple.com/en-us/120421


Quote:
Originally Posted by KevinH View Post
No. I only meant that updating to Sequoia that has been out officially only 2 months is probably not something for everyone.

FWIW, I could already both extend and mirror my screen to my iPad and iPhone using the earlier version of macOS, but to each his own.

Testing and reporting issues is always fine. Thank you.

It is just that early releases of macOS are often very broken and do not get fixed by Apple until many minor releases have come and gone.

If you read my earlier reply, I think this is an extra "security" change by Apple. It is really Qt that vets its software against Apple releases and trues to make sure gui things work.

There have already been two MacOS releases that crashed for no reasons which we had to track down and work around in Sigil only to undo those changes when Apple and or fixed its issues. You helped test workarounds for both of them.

Last edited by odamizu; 12-22-2024 at 06:08 PM.
odamizu is offline   Reply With Quote
Old 12-22-2024, 08:00 PM   #15
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 44,466
Karma: 167726775
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by odamizu View Post
I see. So having been so reckless as to update to the latest macOS 3 months after release (instead of waiting a full year), I should not report issues (which constitutes kvetching?) but instead wait for the developers to update a test machine (next fall) and discover the issue on their own? Because to do otherwise constitutes unwanted kvetching? Really?
More that I expect to have issues with new OS releases. Apple and Microsoft seem to playing games with their security models and that has caused problems for me with quite a few programs. Those issues are probably best handled by being reported on the issues section of the Sigil GitHub page.
DNSB is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Metadata Source Plugin] Empty Plugin? (Fake Identifier) mneimeyer Plugins 3 11-11-2019 08:07 PM
[Plugin] QuickPrefsEdit - Edit plugin prefs json files. slowsmile Plugins 3 07-25-2018 08:14 PM
Goodread Perception Expander plugin not shown on plugin list (kobo h2o) www KOReader 4 09-28-2017 10:34 AM
Problem with my ScrambleEbook plugin and the Plugin Updater tool jackie_w Development 14 01-19-2017 10:49 PM
Plugin not customizable: Plugin: HTML Output does not need customization flyingfoxlee Conversion 2 02-24-2012 02:24 AM


All times are GMT -4. The time now is 10:04 PM.


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