w3c / publ-cg

EPUB 3 Community Group Repository
Other
44 stars 16 forks source link

Reading System Overrides and Basic EPUB3 CSS File #9

Open teytag opened 7 years ago

teytag commented 7 years ago

Hi @dauwhe

I have read the "Reading System Overrides" and references to the wiki page. In order to contribute to the revision of EPUB 3.1, I expressed my ideas on the subject in terms of references. (9 items)

With the "Basic EPUB3 CSS file (normalize.css)" and "metadata"

1.

The "Basic EPUB3 CSS file" will of course not carry a valid document quality in order to display each content. This is not possible. This document should be prepared taking into account the important standards for better viewing of the e-book. I believe it is important for the revision of EPUB 3.1.

2.

EPUB design is as difficult as making a chocolate box design. I agree with the opinion that the text formatting information of EPUB3 format creators is low. RS developers have developed a defender for dealing with nightmare files and have created an improvement by activating UA basic styles. With "Basic EPUB3 CSS file", there will be a technical increase in the quality of the formatting. This will provide an average balance in the imaging capabilities of the reading systems. Developers will no longer deal with problematic files.

3.

The reading system needs a metadata file to ignore the author's CSS document. In a sense, this metadata data will be like a "do not intervene please" intervention. Professional designers need this. The example given by @rdeltour -> rendition: default-css -> https://github.com/w3c/publ-epub-revision/issues/672#issuecomment-198036360

4.

Especially for the reflowable design, the contents of the element must then be used strictly within a <div> element. The basic ground must be established to implement the "box-model" design with the basic CSS values (relative or absolute) to be given to the<div> element. In fact, this <div> element should be passed through the "test-validate" operation in every XHTML.

<style type="text/css" media="screen">
    @namespace epub "http://www.idpf.org/2007/ops";
    div[epub|type~="bodymatter"] {
        ...
    }
</style>
<body>
    <div epub:type="bodymatter">
        <section>
            ...
    </section>
    </div>
</body>

5.

In order to improve the reading experience in EPUB3 format books, we produce user-oriented icons with dynamic CSS. In the text; [W] Web link [L] Navigation between pages (@) Email [S] Dictionary (words with technical meaning) We customize the <a> elements with CSS. So we try to help the user during reading. Such visual standards may be in "basic CSS". I think it will be useful.

a[href*="#"]{color:blue;text-decoration:none;font-weight:bolder;}
a[href*="#"]:after{font-family:Helvetica,Arial,sans-serif;background:blue;content:"S";color:white;padding:2px 5px 3px 5px;margin:-5px 0 0 4px;font-weight:bolder;font-size:60%}
a[href*=".xhtml"]{color:#6A2A07;text-decoration:none;font-weight:bolder;}
a[href*=".xhtml"]:after{font-family:Helvetica,Arial,sans-serif;background:#6A2A07;content:"L";color:white;padding:2px 5px 3px 5px;margin:-5px 0 0 4px;font-weight:bolder;font-size:60%}
a[href^="http:"]{color:#6A2A07;text-decoration:none;font-weight:bolder;}
a[href^="http:"]:after{font-family:Helvetica,Arial,sans-serif;background:#6A2A07;content:"W";color:white;padding:2px 5px 3px 5px;margin:-5px 0 0 4px;font-weight:bolder;font-size:60%}
a[href^="https:"]{color:#6A2A07;text-decoration:none;font-weight:bolder;}
a[href^="https:"]:after{font-family:Helvetica,Arial,sans-serif;background:#6A2A07;content:"W";color:white;padding:2px 5px 3px 5px;margin:-5px 0 0 4px;font-weight:bolder;font-size:60%}
a[href^="mailto:"]{text-decoration:none;color:limegreen;padding:0 5px 0 0;font-weight:bolder;}
a[href^="mailto:"]:link{text-decoration:none;color:limegreen;padding:0 5px 0 0;font-weight:bolder;}
a[href^="mailto:"]:visited{text-decoration:none;color:limegreen;padding:0 5px 0 0;font-family:Helvetica,Arial,sans-serif;font-weight:bolder;}
a[href^="mailto:"]:after{font-family:Helvetica,Arial,sans-serif;background:limegreen;content:"@";color:white;padding:4px 5px 3px 5px;margin:0 0 0 4px;border-radius:15px;font-weight:bolder;font-size:90%}

screen shot 2017-05-30 at 4 28 30 pm screen shot 2017-05-30 at 4 28 38 pm

6.

The cover should be the appropriate CSS for the XHTML page. It may be useful to use the SVG element in this page.

<style type="text/css" media="screen">
    @namespace epub "http://www.idpf.org/2007/ops";
    div[epub|type~="cover"] {
        ...
    }
</style>
<body>
    <div epub:type="cover">
        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="100%" height="100%" viewBox="0 0 916 1197" preserveAspectRatio="none">
            <image width="916" height="1197" xlink:href="image/cover.jpg"/>
        </svg>
    </div>
</body>

7.

It would make sense to try to list the "default values" of new HTML5 elements such as Section, Aside. I want to be among those who will do this work. @dauwhe is the opinion owner. -> https://github.com/w3c/publ-epub-revision/issues/672#issuecomment-198384038

8.

It would be good to look at the work done by @JayPanoz to examine the CSS values of reading systems in creating the "basic EPUB3 CSS file". Thus, we can predict the values that can coincide with UA style sheets. -> https://github.com/FriendsOfEpub/WillThatBeOverriden/tree/master/ReadingSystems

9.

EPUB3 CG CSS Themes: In the following years we can build EPUB3 CG CSS Themes to simplify the work of authors. For example, we can increase the "design and render quality" by providing the use of standards elements. I am sure there are people who work like me in this regard. Even @JayPanoz has worked on this issue -> https://github.com/w3c/publ-epub-revision/issues/672

JayPanoz commented 7 years ago

Mmmkay, a few thoughts.

With "Basic EPUB3 CSS file", there will be a technical increase in the quality of the formatting.

I must admit I’m a little bit uncomfortable with the idea of “normalize.css”, since it’s been the realm of CSS authors. What we should be probably talking about is “suggested rendering”, à la HTML5.

Now, it is my understanding that apps relying on web views or web apps (in the browser) are already leveraging it.

The stuff I don’t really like in there is horizontal spacing in pixels e.g. margin-left: 40px; or padding-left: 40px;, which can be 20% of the container in some cases and 0.03% in some others, should an app have a viewport the size of the physical pixels…

But basically, we’re covered there, even the old RMSDK and Kindle have some sort of default rendering albeit not HTML5, so it seems to me this is not that big an issue after all. Even made another small CSS framework for that and you could almost perfectly rely on that.

Fact is it doesn’t prevent bad CSS, because this is not much of a technical than a human issue. It’s about people, the tools they use, the software designers they trust, the hacks they design, the overrides they fight, etc.

When people are putting double spans around a sentence to make sure it will render in the embedded font they declared for this element, there’s little you can do.

"do not intervene please" intervention.

See my previous paragraph (technical/human).

When designing blitz, I became aware how easy it is to screw up user settings for instance. In some cases, use some web CSS snippets and BOOM, some user setting doesn’t work anymore. Nobody knows how much effort it actually required, and we ended up “abusing” the cascade and inheritance to make it work. The reset, which may look simplistic at first sight, is the result of months of debug/QA/author testing. And yeah, I discovered I previously fucked up some user settings in some Reading Systems, I didn't know and I paid an insane amount of attention to that.

I mean, such a metadata is bound to fail in my opinion. If that can be any signal, Amazon automates CSS changes (fonts, color, size, etc.) which break user settings or provide readers with a shitty reading experience (contrast). It means that enough files were problematic to invest in that automation. It’s probably in the dozens of thousands, if not more.

It is now my belief user settings is one critical issue on which we should focus.

Finally, you have to take “tag soup” into account. How are RS devs supposed to cope with an infinite amount of “tags + classes” combo? Sure, you could say “never mind, we’ll do it anyway, the problem with fix itself” but it will require years, the back catalog won’t likely be updated and

div.aside {
  /* Styles */
}

won’t at least be a visual aside, which is likely to create comprehension issues because maybe there was a border and now there isn’t and you don’t understand what the author is saying anymore.

It’s not like amp, Instant Articles or Apple News, in which there is a set of pre-defined building blocks you can use or else it won’t work, thus making it completely overridable for the Reading System.

Especially for the reflowable design, the contents of the element must then be used strictly within a <div> element.

Sorry, I don’t get this part to be honest.

One important issue to note though is that, when CSS multicol is involved, there’s not much you can do about it. Web developers have had issues with that too, because positioning, offsets, etc. in columns are terrible (negative offsets, etc).

It actually blows my mind the multicol spec has not been updated/discussed for so long, especially as Apple, for instance, is using it for iBooks. Instead, they designed crappy JS hacks to make some stuff happen…

I’m convinced that in order to really solve this issue, we’ll need a CSS multicol Level 4 at some point, if only to renew interest in their implementations because it is super hostile to the new layout specs (flexbox and grid, for which there are nasty bugs currently).

But another problem is, you could use JS to solve some problems but… at the time you get all the accurate data you need, pagination is over and out, and you can't force a recalc.

It may be useful to use the SVG element in this page.

Some reading systems are already lukewarm to using SVG for images and demotivate it. I know we’ve been using this a lot because of Adobe’s ePub2 RMSDK but there are so many issues with figures that this one doesn't look so important to me, especially as there’s object-fit now.

It would be good to look at the work done by @JayPanoz to examine the CSS values of reading systems in creating the "basic EPUB3 CSS file". Thus, we can predict the values that can coincide with UA style sheets.

As far as I can tell, there’s none because you have to think in terms of whole declarations, and not specific values.

Most stylesheets are the result of the following:

  1. how pagination is achieved.
  2. “hacks” to make some stuff play nicely in this pagination, with the most minimal impact possible on the authors’ CSS.
  3. overrides compensating for problematic files (because there is a large amount of those files, which stylesheets are typically output by authoring software).
  4. styles to set up or apply user settings.

So it vastly depends on the Reading System itself.

It’s worth repeating blitz just make it more predictable on the authors’ end, and try helping them not break user settings but that’s it. It’s just default values. Should an author put a problematic style in there, it will become an issue.

You could probably build a comprehensive list of best practices for overrides, i.e. “this stuff has been painful to us, could you please pay attention to it when designing your CSS?”

I guess RS devs would welcome that much much better that any metadata, etc. Don’t forget it’s also a business for them and should they implement that and crappy files generate reimbursements as a result, it won’t last long.

JayPanoz commented 7 years ago

Especially for the reflowable design, the contents of the element must then be used strictly within a <div> element.

If I may, an additional word of caution about that: it can screw up inheritance (and the cascade).

I had to deal with some nasty bug with a test file in Kobo iOS and Android at some point; all contents were centered, even text.

It appeared it was because I dropped a quick and dirty text-align: center for div because I used it only as images’ containers, but Kobo apps wrapped the whole XHTML file’s contents in a div. In other words, all contents inherited this text-align declaration.

There are probably some files out there with styles declared for div, which would have an impact in this case.

JayPanoz commented 7 years ago

OK, if I may, a new perspective on this since I’ll be on the RS side for the next three months.

normalize.css

Have documented browsers’ UA stylesheets this week, and believe me, it was kind of painful.

What's important there is that you can use sanitize.css or normalize.css or Eric Meyer’s reset.css, which all already exist. And nothing prevents you from customizing it. So it’s more about culture than providing a normalize-epub.css people would have to retro-fit in their existing workflow.

"Basic EPUB3 CSS file"

Unless you make its absence an epubcheck error, I can’t see how you can get everyone on board—spoiler, making it an error would probably create a shitstorm.

The reading system needs a metadata file to ignore the author's CSS document.

Related: responsibility of UI is currently discussed for Web Publications.

Especially for the reflowable design, the contents of the element must then be used strictly within a <div> element.

It breaks cascading and the inheritance, possibly viewport units (vh since vw is already unusable), may conflict with authors’ styles, etc. This div element won’t automagically solve the box-model issue in columns for instance, which are used for pagination. We need a better standard for pagination (also, some Reading Systems already declare position: relative|absolute, and this hasn’t solved this issue).

Such visual standards may be in "basic CSS". I think it will be useful.

As far as I’m concerned, that’s an author’s preference, it shouldn’t find itself in an “official” stylesheet.

The cover should be the appropriate CSS for the XHTML page.

This is one of the issues I’ll have to tackle but I already have a solution, and SVG is not required at all (you can use it if you want but it’s two extra lines of CSS in any case).

It would make sense to try to list the "default values" of new HTML5 elements such as Section, Aside.

You’ll find them in HTML Suggested Rendering.

Have spent 2 days validating major browsers’ UA stylesheets against suggested rendering and there’s no nasty surprise there.

examine the CSS values of reading systems in creating the "basic EPUB3 CSS file". Thus, we can predict the values that can coincide with UA style sheets.

Having spent part of the last week discussing how to address pagination, user settings, default styles and stuff, can confirm the following:

Most stylesheets are the result of the following:

  1. how pagination is achieved.
  2. “hacks” to make some stuff play nicely in this pagination, with the most minimal impact possible on the authors’ CSS.
  3. overrides compensating for problematic files (because there is a large amount of those files, which stylesheets are typically output by authoring software).
  4. styles to set up or apply user settings.

So it vastly depends on the Reading System itself.

In some Reading Systems, bugs authors experience might just be side effects, but trust me, it currently takes tremendous effort to find compromises so that those side effects don’t happen.

In the following years we can build EPUB3 CG CSS Themes to simplify the work of authors. For example, we can increase the "design and render quality" by providing the use of standards elements.

That’s authors’ territory, not specs. See how many CSS frameworks exist for the web and how little exist for ebooks. So, once again, this is a cultural issue. You won’t improve that with specs, you’ll improve that with evangelization—which is pretty hard if the effort is not collective.

Or you can check Dave’s EPUB Zero repo and try to make that happen at the industrial scale.