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 06-25-2020, 02:46 PM   #46
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,589
Karma: 14328510
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by DNSB View Post
But @mcdummy did not want the undefined classes removed. He wanted to be informed about them so he could add the required classes. For that, I thought the Report tool was an already implemented solution.
Nevertheless it would still be useful if the plugin removed them from the CSS files. As an option.

Along those lines I've had times when a book has a lot of "crud" html and it would have been nice if Sigil's Report thing would list all of the used html tags.
hobnail is offline   Reply With Quote
Old 06-25-2020, 02:48 PM   #47
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,589
Karma: 14328510
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by DNSB View Post
But @mcdummy did not want the undefined classes removed. He wanted to be informed about them so he could add the required classes. For that, I thought the Report tool was an already implemented solution.
Nevertheless it would still be useful if the plugin removed undefined CSS as well as unused CSS. As an option.

Along those lines I've had times when a book has a lot of "crud" html and it would have been nice if Sigil's Report thing would list all of the used html tags.

Last edited by hobnail; 06-25-2020 at 02:50 PM.
hobnail is offline   Reply With Quote
Advert
Old 06-25-2020, 02:55 PM   #48
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,803
Karma: 6000000
Join Date: Nov 2009
Device: many
FWIW, There is no such thing as "unused" html tags. Under the html5 spec you can actually define your own tags. These can be processed using javascript as well.
KevinH is offline   Reply With Quote
Old 06-25-2020, 03:04 PM   #49
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,589
Karma: 14328510
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by KevinH View Post
FWIW, There is no such thing as "unused" html tags. Under the html5 spec you can actually define your own tags. These can be processed using javascript as well.
I was thinking along the lines of the book using things like blockquote when it clearly wasn't a quote, or h5 for bolding.
hobnail is offline   Reply With Quote
Old 06-25-2020, 03:05 PM   #50
hobnail
Running with scissors
hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.hobnail ought to be getting tired of karma fortunes by now.
 
Posts: 1,589
Karma: 14328510
Join Date: Nov 2019
Device: none
Quote:
Originally Posted by KevinH View Post
FWIW, There is no such thing as "unused" html tags. Under the html5 spec you can actually define your own tags. These can be processed using javascript as well.
Do you need to provide a schema?
hobnail is offline   Reply With Quote
Advert
Old 06-25-2020, 03:06 PM   #51
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,796
Karma: 146391129
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by DNSB View Post
I suppose cssRemoveUnusedSelectors plugin could be modified so undefined classes would be added to the stylesheet as a blank selector ( .whatever {} ) but not sure how much easier that would make the job. Are you volunteering to code and test this?
Thing is, there are a lot of eBooks that have nonexistent classes in the HTML. Some of those classes ae used in place of an ID. The others, I have no idea why they are there or why the CSS is missing those classes.
JSWolf is offline   Reply With Quote
Old 06-26-2020, 02:38 AM   #52
mcdummy
Connoisseur
mcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the rough
 
mcdummy's Avatar
 
Posts: 73
Karma: 7130
Join Date: Apr 2015
Device: PRS-T3
Thanks to comments by @DNSB and @hobnail.

It would be good to have both an information showing the undefined/non-existing classes and an option to remove those of them that a user does not want to keep.

A manual removal could be quite complicated, since I've seen constructions like class="class1 class2 ... classN", which makes it difficult to remove a specific class (even with regex) if it has a "conventional" name like "center" or the name of class2 (e.g., heading, author) is also a part of classN (e.g., subheading, co-author).

An option for the generation of empty classes for the ones that are kept would be the icing on the cake.

I don't know if this already exists in the plugin, but since there's a discussion about code additions.

I've seen style sheets contain class definitions two or more times. Therefore, it would be good, if these definitions were merged.

I further noticed that sometimes classes contain the same instruction several times but with different values, e.g., "text-align: left" followed later by "text-align: right". Since only the last definition will be applied, it would be advantageous to remove the first.
mcdummy is offline   Reply With Quote
Old 06-27-2020, 01:00 PM   #53
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: 43
Karma: 588278
Join Date: Apr 2016
Device: none
Hi mcdummy,
I'd rather think about providing a different plugin that could automatically remove unmatched classes in xml/xhtml than modifying this one. That's because this plugin is designed to run as safely as possible on as many epubs out there as possible, and in doing so it changes absolutely nothing outside of css files. Adding this feature would open a whole new set of issues and edge cases to be worried about.

If (but that's a big if) I find the time in the next days I'll try to put something together (but if someone else wants to step up, please feel free to do so).

About the other suggestions, I find them interesting, and I'll think about them a bit more, although I'm not totally convinced. These are my thoughts for now.

Just showing the classes unmatched by a selector is already done by the Reports tool as DNSB pointed out.

About merging rulesets, I think that's not impossible, but that's not totally safe either:
Code:
.classA {}
.classB { color: red }
.classA { color: blue }
is not the same as
Code:
.classA { color: blue }
.classB { color: red }
for a tag like <p class="classA classB">.

Quote:
Originally Posted by mcdummy View Post
I further noticed that sometimes classes contain the same instruction several times but with different values, e.g., "text-align: left" followed later by "text-align: right". Since only the last definition will be applied, it would be advantageous to remove the first.
True, unless the rendering engine of the epub reader decides that the last property has an invalid value: in that case it will use (probably) the first one.

@hobnail: I'm not sure I understood your last posts: do you have a specific proposal or were you simply backing the request of mcdummy?
wrCisco is offline   Reply With Quote
Old 06-29-2020, 10:22 AM   #54
mcdummy
Connoisseur
mcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the roughmcdummy is a jewel in the rough
 
mcdummy's Avatar
 
Posts: 73
Karma: 7130
Join Date: Apr 2015
Device: PRS-T3
Quote:
Originally Posted by wrCisco View Post
I'd rather think about providing a different plugin that could automatically remove unmatched classes in xml/xhtml than modifying this one. That's because this plugin is designed to run as safely as possible on as many epubs out there as possible, and in doing so it changes absolutely nothing outside of css files. Adding this feature would open a whole new set of issues and edge cases to be worried about.
I'm happy with a separate plugin, if it both indicates the unmatched classes and provides an option to select those that should be deleted. Automatic deletion is a bit disadvantageous, since I often want to keep some of the classes and add the definitions to the css.

Quote:
Originally Posted by wrCisco View Post
Just showing the classes unmatched by a selector is already done by the Reports tool as DNSB pointed out.
Combining the report and deletion in one tool makes things easier.

Quote:
Originally Posted by wrCisco View Post
About merging rulesets, I think that's not impossible, but that's not totally safe either:
Code:
.classA {}
.classB { color: red }
.classA { color: blue }
is not the same as
Code:
.classA { color: blue }
.classB { color: red }
for a tag like <p class="classA classB">.
Was not aware of this problem. It would be good to be informed about double defintions either of classes or within a class. An option to merge or delete double definitions would be great.
mcdummy is offline   Reply With Quote
Old 08-22-2020, 01:24 PM   #55
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: 43
Karma: 588278
Join Date: Apr 2016
Device: none
Quote:
Originally Posted by mcdummy View Post
I'm happy with a separate plugin, if it both indicates the unmatched classes and provides an option to select those that should be deleted. Automatic deletion is a bit disadvantageous, since I often want to keep some of the classes and add the definitions to the css.
Hi, I uploaded last week the plugin you requested (here's the thread) and forgot to mention it here...

Meanwhile, I uploaded version 0.3.2 of this plugin with an icon for displaying in Sigil.
wrCisco is offline   Reply With Quote
Old 09-20-2024, 05:03 AM   #56
Capricorn
Belgian Pommes Frites
Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.
 
Posts: 122
Karma: 35038
Join Date: Jan 2012
Device: Pocketbook Touch HD
I use this plugin regularly, and it does a very good job. Thank you.
I have now incorporated it into an automate list in Sigil.
Is there a way to run this plugin without user interactions, when using an automate list?

Last edited by Capricorn; 09-20-2024 at 10:44 AM.
Capricorn is offline   Reply With Quote
Old 09-20-2024, 09:40 AM   #57
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: 43
Karma: 588278
Join Date: Apr 2016
Device: none
I'm glad that this plugin is still useful to someone (Unless you are stuck with an old version of Sigil, the built-in Sigil function should now be just fine to use for all selectors and not just for classes).
Right now there isn't a way to bypass the GUI, but it should be fairly easy to add a preference in the json file to tell the plugin to just delete all the unused selectors without asking. I'll look into it.
wrCisco is offline   Reply With Quote
Old 09-20-2024, 10:42 AM   #58
Capricorn
Belgian Pommes Frites
Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.
 
Posts: 122
Karma: 35038
Join Date: Jan 2012
Device: Pocketbook Touch HD
Ah....I am using Sigil v2.3.1, but I hadn't realised that the built-in function is now as good as the plugin. I will have a look at it and see if there may still be small differences or not.
But if I could use this plugin without user interaction within an automate list, that would still be an advantage compared to the built-in function. Thank you very much for looking into it. That would be very nice indeed to have.
Capricorn is offline   Reply With Quote
Old 09-20-2024, 08:12 PM   #59
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: 43
Karma: 588278
Join Date: Apr 2016
Device: none
I uploaded a new version of the plugin that should handle the 'quiet' part.
In order to activate the new functionality, you need to manually update the preferences file in $SIGIL_PREFS/plugin_prefs/cssRemoveUnusedSelectors/cssRemoveUnusedSelectors.json, adding the line
Code:
"quiet": true
E.g.
Code:
{
  "parseAllXMLFiles": true,
  "indent": "    ",
  "indentClosingBrace": true,
  "keepEmptyRules": true,
  "omitLastSemicolon": true,
  "omitLeadingZero": true,
  "formatUnknownAtRules": false,
  "linesAfterRules": "\n",
  "quiet": true
}
After that, it should only interact with the user when there are errors that stop the execution. Let me know if it works okay.
Attached Files
File Type: zip cssRemoveUnusedSelectors_0.3.4beta.zip (24.0 KB, 92 views)
wrCisco is offline   Reply With Quote
Old 09-21-2024, 06:30 AM   #60
Capricorn
Belgian Pommes Frites
Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.Capricorn turned on, tuned in, and dropped out.
 
Posts: 122
Karma: 35038
Join Date: Jan 2012
Device: Pocketbook Touch HD
I have now managed to test it on about 20 books. In a number of them I had already removed any unused selectors, and it just continues on to the next plugin in my automate list without giving any messages. In the other cases it did give a message that some selectors needed to be removed.
So, yes, so far it works. I will continue to use it, and see if something may still trip it up or not.

Very, very nice. THANK YOU.
Capricorn is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] KindleUnpack - The Plugin DiapDealer Plugins 523 07-15-2025 06:45 PM
[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


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


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