![]() |
#1 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,629
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Check non existent css styles
Hi,
I don't know if this has been asked. Is there any way to check that there is a style in the html files that it is not included in any stylesheet? Thank you in advance. |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I'm not sure what you mean by a style in a html file that is not included in a stylesheet. If you mean check for unused CSS style rules, there is a tool to remove those under the Tools menu.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
OP wants to know if there is anything for the exact opposite -- a css style used in the html which does nothing since it is never defined in a stylesheet/style tag.
Unless a new stylesheet rule gets added, the css invocation might as well be stripped the same way unused stylesheet rules are. |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Remove unused stylesheets removes css rules from inside <style> tags as well. And css declarations in style attributes are never unused.
And note that unused and 'do nothing' are different concepts, the latter being a superset of the former. |
![]() |
![]() |
![]() |
#5 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,629
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Sorry I haven't explained better. I mean: in html file you have <p class="par1">, but par1 is not defined. Can this be checked?
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No, there is no code to do that. Note that in general css selectors can operate on any attribute of an html tag, not just class.
|
![]() |
![]() |
![]() |
#7 |
Ex-Helpdesk Junkie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 19,421
Karma: 85400180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
|
Who said anything about unused? And of course unused css gets removed from style tags as well, bad phrasing.
![]() They are do-nothing tags, agreed. ![]() ![]() |
![]() |
![]() |
![]() |
#8 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I dont see much point, as I said to the OP, css selectors can operate on any attribute, not just class. So removing only class attributes seems a little unfair
![]() And class can be used for other purposes than just css. It can be used in javascript selectors for instance. Or it can be used for semantic annotation. Law of diminishing returns, but hey, patches are welcome. I wont refuse a tool to do that. |
![]() |
![]() |
![]() |
#9 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,629
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Thank you very much. I think I agree with kovid it's not so interesting to spend the time doing it but, if it was there, I could use it.
|
![]() |
![]() |
![]() |
#10 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
Another vote for this possible check if someone can spend some time and knowledge in it. Kovid has explained why undefined css classes are not an error, but I do think that they will usually come from typos or other user errors while manually editing a book, so a warning in Check Book could be pretty handy.
(An example I happily seldom do any more: forgetting about setting up the .nw class as I explain in my post in the Saved Searches thread). Last edited by arspr; 06-13-2014 at 02:48 AM. |
![]() |
![]() |
![]() |
#11 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 817
Karma: 6528026
Join Date: Sep 2012
Device: Kobo Elipsa
|
I use Sigil's reports to check for classes that are not defined in the stylesheet. It's the only thing I use Sigil for anymore, and I would love for Calibre's editor to warn me that I am using a class that is not defined in the stylesheet.
|
![]() |
![]() |
![]() |
#12 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,349
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
![]() |
![]() |
![]() |
#13 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,629
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
|
Thank you very much.
|
![]() |
![]() |
![]() |
#14 |
Dead account. Bye
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 587
Karma: 668244
Join Date: Mar 2011
Device: none
|
Yes, Kovid, thanks a lot
|
![]() |
![]() |
![]() |
#15 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,166
Karma: 1410083
Join Date: Nov 2010
Location: Germany
Device: Sony PRS-650
|
+1.
![]() |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modding Calibre CSS styles | Olger | Recipes | 7 | 01-25-2012 05:08 AM |
CSS: Styles for <cite> won't apply | kevlin | Sigil | 4 | 01-11-2012 12:29 PM |
CSS Table Styles: Does it work? | Alan Newson | ePub | 3 | 12-12-2011 03:54 PM |
Tool to centralise css styles? | snarkophilus | ePub | 7 | 07-01-2011 04:08 AM |
Sigil styles and CSS | View[+]Finder | Sigil | 4 | 05-27-2010 05:39 PM |