← Back to team overview

calibre-devs team mailing list archive

Re: CSS normalization

 

Should be an easy enough fix. When extracting CSS from style attributes, if the 
tag already has a class, instead of creating a class based selector, create an 
id based selector (giving the element a new id if it doesn't already have 
one). 

That should cover this case, as well as a few others. If you agree, I';; go 
ahead and implement it.

Kovid.

On Sunday 25 January 2009 12:35:29 Marshall T. Vandegrift wrote:
> Hi Kovid etc:
>
> Ticket #1654 has revealed a fairly deep bug in the way any2epub does CSS
> normalization.  The basic scenario is that the source has CSS and markup
> like this:
>
>     p.prelims { text-align: left; }
>
>     <p class="prelims" style="text-align: center">TOR</p>
>
> Calibre is currently turning that into:
>
>     p.prelims { text-align: left; }
>     .calibre_class_6 { text-align: center; }
>
>     <p class="prelims calibre_class_6">TOR</p>
>
> In the original, the implicit rule provided by the 'style' property has
> the highest specificity, and the text is centered.  In the generated
> CSS+markup, the '.calibre_class_6' rule has a lower specificity than the
> 'p.prelims' rule, and the text ends up being left-aligned instead of
> centered.
>
> In the CSSFlattener transform I collapse all CSS rules into single-class
> class selectors, which circumvents this problem.  It does deform the
> original source CSS rules, but practically speaking I'm not sure the
> number of generated rules any2epub presently creates serves the purpose
> of producing human-legible CSS much better...
>
> Probably not a hugely frequent problem, but definitely a bug.
>
> -Marshall
>
> _______________________________________________
> Mailing list: https://launchpad.net/~calibre-devs
> Post to     : calibre-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~calibre-devs
> More help   : https://help.launchpad.net/ListHelp
>
> !DSPAM:3,497ccd1a75722880110530!

-- 
_____________________________________

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : kovid@xxxxxxxxxxxxxxxxxx
web   : http://www.kovidgoyal.net
_____________________________________




References