Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 09-13-2019, 03:23 PM   #1
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 310
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
remove unused CSS rules

I just noticed that when there is an unused class sometimes it will not be removed. Is that because it is in a comma series?

ol, .someunusedclass, ul {
font: 0.75em/1.2 "Ubuntu";
background-color: khaki;
display: inline-block;
width: 100%;
}

Best regards, Pop
rjwse@aol.com is offline   Reply With Quote
Old 09-13-2019, 05:21 PM   #2
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 195
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
Yes, when CSS selectors are "stacked" in the comma separated form, the "remove unused rules" tool does not work. I use a regex to separate out the rules:

--unstack selectors so Calibre "Remove unused rules" tool can be used:

Search: ([.]?[^ ]+),\s([^{]+)(\{[^}]+\})
Replace: \1 \3\n\n\2\3

'Replace All' until 0 returns. Clean CSS, then restack or replace class selectors. Apply early in edit session.
Brett Merkey is offline   Reply With Quote
Advert
Old 09-14-2019, 12:08 AM   #3
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,653
Karma: 24966646
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
remove unused classes removes class from class attributes in tags not classes from style rule selectors. Since that rule is used presumbaly because you have ol or ul tags in your book, it wont be removed.
kovidgoyal is offline   Reply With Quote
Old 09-14-2019, 08:41 AM   #4
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 195
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
Quote:
Since that rule is used presumbaly because you have ol or ul tags in your book, it wont be removed
The "remove" tool cannot be relied upon with stacked selectors.
TEST:
1) create stacked selector rules where clearly none are used. The tool removes ALL rules in whatever class/tag form.
2) add a rule into this stack that is clearly used. Run the tool. NONE of the selectors are removed.

So if a stack of bad selectors contains one good selector, the ruleset is not cleaned. NO selectors are removed. The selectors have to be unstacked before the tool is applied.

Last edited by Brett Merkey; 09-14-2019 at 08:48 AM.
Brett Merkey is offline   Reply With Quote
Old 09-14-2019, 10:02 AM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,653
Karma: 24966646
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Its a remove unused CSS tool not a remove unused selectors tool.
kovidgoyal is offline   Reply With Quote
Advert
Old 09-16-2019, 09:11 AM   #6
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 310
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
separate comma-stacked CSS

Thanks for the info, everyone. I put Brett Merkey's regex into my "saved searches" and tried it out. It works good. As you may notice from the screenshot I am overzealous using comma-separated items. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2019-09-16 07-03-45.png
Views:	245
Size:	365.3 KB
ID:	173483  
rjwse@aol.com is offline   Reply With Quote
Old 09-16-2019, 09:44 AM   #7
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: 76,960
Karma: 138588794
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Personally, I dislike multiple classes put together even if the CSS code is the same. I's cleaner and neater to do it one at a time. That also give the advantage if you need to change one of the classes, you can very easily. And if you sort the classes alphabetically, they will be sorted in the correct order.

I'm not a fan of some CSS shortcuts such as stacking classes and margin:.
JSWolf is offline   Reply With Quote
Old 09-16-2019, 09:57 AM   #8
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 195
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
@ JSWolf

I agree with you on stacking selectors. But...

Quote:
And if you sort the classes alphabetically...
Sorting a well-constructed stylesheet is the fastest way of destroying it. You can construct a smaller, more flexible, more powerful stylesheet by working with the cascade. I know that Calibre has a tool to alphabetize selectors but perhaps it is good that the tool is fairly well hidden.

Last edited by Brett Merkey; 09-16-2019 at 10:14 AM.
Brett Merkey is offline   Reply With Quote
Old 09-16-2019, 10:14 AM   #9
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,405
Karma: 12408443
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by Brett Merkey View Post
@ JSWolf

I agree with you on stacking selectors. But...



Sorting a well-constructed stylesheet is the fastest way of destroying it. You can construct a smaller, more flexible, more easily modifiable stylesheet by working with the cascade. I know that Calibre has a tool to alphabetize selectors but perhaps it is good that the tool is fairly well hidden.
I disagree, trust on the css order (or any order) is a very nice way to doom your book.
Terisa de morgan is offline   Reply With Quote
Old 09-16-2019, 10:35 AM   #10
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: 76,960
Karma: 138588794
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 Brett Merkey View Post
@ JSWolf

I agree with you on stacking selectors. But...



Sorting a well-constructed stylesheet is the fastest way of destroying it. You can construct a smaller, more flexible, more powerful stylesheet by working with the cascade. I know that Calibre has a tool to alphabetize selectors but perhaps it is good that the tool is fairly well hidden.
I highly dislike any CSS that requires it to be in a specific order. There's no need of it. It's best to use classes in the code instead of stacking so classes are not needed.

Trying to shorthand can come back to bite you. For example, using margin: instead of say margin-left: etc. can bit you if it's on an older nook.

Just do it all long form and you'll be better off.
JSWolf is offline   Reply With Quote
Old 09-16-2019, 11:20 AM   #11
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: 30,506
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
even with a stacked CSS
a later selector can override the prior declaration. The later one may be for just 1 attribute.
Code:
.CO {text-indent: 0}
Alphabetizing or deleting prior selectors may alter the results. remember it is Css.

Granted, Wolf's Way, is easier to troubleshoot, but it is not the only way.

blockquote p {
theducks is offline   Reply With Quote
Old 09-17-2019, 06:03 PM   #12
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 310
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
I was completely smitten by the brevity of the descendant combinator such as:

<style>
.dash {list-style: none;}
.dash li:before { content: " — "; margin-left: -2em;}
</style>

This puts a dash instead of a number or a bullet in front of <li> if surrounded by either <ol> or <ul>.

You can even use * to denote any tag enclosed by the class:
<style>
.whatever * {
do:this; do:that;
}</style>

I'm confused on how combinators, tags, and classes get put into alphabetical order.

Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2019-09-17 15-48-18.png
Views:	210
Size:	426.4 KB
ID:	173520  
rjwse@aol.com is offline   Reply With Quote
Old 09-17-2019, 08:00 PM   #13
Brett Merkey
Not Quite Dead
Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.Brett Merkey ought to be getting tired of karma fortunes by now.
 
Posts: 195
Karma: 654170
Join Date: Jul 2015
Device: Paperwhite 4; Galaxy Tab
Quote:
I'm confused on how combinators, tags, and classes get put into alphabetical order.
Good question. If you are asking about how to access the tool within Calibre, well, it is mercifully hidden within the Edit > Preferences menu within the Calibre Edit module.
If you are asking what alphabetical order means within a potential zoo of combinators, contextual selectors, pseudo-classes and pseudo-elements, then a lot of head-scratching awaits you when you actually test the tool.

Take a very simple contextual selector as an example: it is obvious that rules for blockquote will come before body in a sorted sheet. But where does the contextual selector blockquote p (styling paragraphs within a blockquote) reside in the sort? Hint: nowhere near blockquote.

Sorting a sheet may be of use if you are dealing with a huge jumble of CSS and you need to find something — but that something you want to find needs to be real simple and you need to remember to unsort immediately to retain control of the cascade.

Last edited by Brett Merkey; 09-17-2019 at 08:24 PM.
Brett Merkey is offline   Reply With Quote
Old 09-18-2019, 10:39 AM   #14
rjwse@aol.com
Addict
rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.rjwse@aol.com ought to be getting tired of karma fortunes by now.
 
rjwse@aol.com's Avatar
 
Posts: 310
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
alphabet sort icon when stylesheet.css is open

When the stylesheet.css is onscreen in the editor you can use the A-Z alphabetizing icon to reorder the stylesheet. I use it all the time with a different philosophy of intent. I prefer the cascade of instructions to (1) begin in the stylesheet (completely independent of order), (2) be overridden by a style command (if present) at the top of each .xhtml segment, (3) finally, be overridden in the text with class="" or style="" in individual tags. For some reason, I have come to think I have made some sort of mistake if the commands in the stylesheet are dependent on their alphabetical place. Still, I am perplexed how the alphabet rules work. Best regards, Pop
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2019-09-18 08-27-18.png
Views:	220
Size:	466.3 KB
ID:	173534  
rjwse@aol.com is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre 3.22: Missing "Remove unused CSS rules" DrChiper Editor 4 04-20-2018 04:39 AM
Inconsistencies in Remove unused CSS rules!? chaot Editor 8 04-28-2016 01:38 PM
Is it possible to reject some changes after using "Remove unused CSS tool"? bowlins Editor 7 09-02-2014 05:22 AM
Remove unused CSS Rules Divingduck Editor 2 06-21-2014 08:51 AM
New "remove unused css" tool BobC Editor 4 01-25-2014 10:06 PM


All times are GMT -4. The time now is 06:02 AM.


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