Quote:
Originally Posted by Hitch
Well...the iterations would be fairly massive, I'd think.
I mean, you'd have to (I don't program, so--those with real brains, leap in) aggregate ALL the styles and elements; probably doing so from the top-down, so most-used to least-used makes the most sense; search for all instances of "p," first, and then all classes used in the ePUB--and then do a string-match in the CSS...does that sound right, ye olden programmers? I mean, it seems more efficient to do it by element and then by class, but sometimes, what seems elementary (sorry, sorry, you guys KNOW I can't resist bad punnage!) isn't.
We use something SOMEWHAT like this in two places; we have a PERL script and an NTPro script that both check for this--but it's in the HTML. I don't know how we'd adopt it to run inside Sigil, unless we took the additional steps of copying the file, merging it, and exploding it, but even so...it would be a SLICK addition in Sigil. I would infinitely rather the "used in the ePUB but not in the stylesheet" functionality than simply cleaning up the Stylesheet. I know some folks need that--and it would be nice fudge topping--but it's not as needed as the inverse. We have a House CSS that we use, so cleanup isn't as important for us, in the CSS itself...but I think everyone would love the missing classes thing.
JMHO,
Hitch
|
I don't know CSS that well, yet, but from what I've seen, the selectors you can use in CSS are very flexible, making it hard to parse. Unless EPUB only uses a subset - something I still need to find out. There are parsers out there, and it may be that one of them might help.
You would have to go through every element and then compare it against every selector to see if there is a match. For finding used but undefined entries you could simplify things by restricting what's checked (ie checking only class attributes and seeing if they match a selector. Checking just for the name doesn't cover everything as a class could only be defined for certain tags...). I created an issue to track this - just reporting on classes used in the HTML.