← Back to team overview

calibre-devs team mailing list archive

Re: CSS normalization

 

On Tue, Jan 27, 2009 at 2:22 AM, Kovid Goyal <kovid@xxxxxxxxxxxxxx> wrote:

> Yeah I agree. The only remaining drawback I can think of is that it
> will mess up class based javascript selectors. I know EPUB isn't
> supposed to support javascript, but I believe that will
> change. However, if I understand the algorithm correctly, that will
> only happen for tags that have style attributes, so it shouldn't be
> too big a deal.

Well actually, it gets applied to all elements.  I should have pointed
this out earlier, but what I'm describing is what's implemented in
calibre.ebooks.oeb.transforms.flatcss.CSSFlattener, so you can check out
what I'm talking about.  Global CSS-simplification and font-size
normalization in one smooth step.

As for keeping the source @class values in the DOM, that wouldn't be too
much of a change to the algorithm.  Instead of re-using existing element
@class names and generating variants as necessary, it would instead use
all generated names, give every elements their original @class values
and a generated one, and write all CSS rules in terms of the generated
names.

That said, I'm not 100% in agreement that preserving the structure would
be useful.  On a technical level, we're already tossing bits of the DOM
around willy-nilly, which risks interfering with the operation of any
script.  On more... philosophical? level, I'm not at all convinced that
scripting is actually of benefit for "books."  I think the defining
feature that makes a book different from an essay, or a large Web site,
or a Web application, or a blog post, or a comment on a blog post, etc
etc, is that a book is such that it requires sustained, largely linear
attention in order to communicate its intended content, whether that be
a story, a substantive argument, etc.  Contrasting that with the way
scripting is used on the Web, "scripting in books" seems to be at best
gimmicky and at worst at cross-purposes with the reason for a particular
piece of content being in "book" form in the first place.

-Marshall



Follow ups

References