Handling CSS mappings is a bit complicated because the W3C setup is not entirely consistent...
In general, the HTML links to a style file of the sort
https://www.w3.org/StyleSheets/TR/2021/W3C-{specStatus}. These files are all very simple:
import a common base.css file and add a setting for the background image using the logo file
(this is, usually, the left stripe in the text).
The logo used with the name https://www.w3.org/StyleSheets/TR/2021/logos/{specStatus}.svg
The references to the logo files use relative URL-s, which is just fine for the EPUB version.
All these files
must be copied into the zip file, and the HTML references must be changed to their relative equivalents.
However… the complication, from EPUB's point of view, mostly for some older or rarely used specification versions. The complications
may be:
The logo references in those CSS files may be absolute URL-s
The logo references may rely on content negotiation, ie, do not spell out whether an SVG or a PNG image is used for a logo (which does not work in an EPUB content)
Some basic formats do not use logo at all.
The references are not relying on the 2021 subtree of the StyleSheets/TR/ directory of the W3C site
The function below handles the exceptional cases separately by storing some css and png files in a fixed place and copy the
files from there (as opposed to using the W3C files directly). This is done instead of performing some extra CSS parsing.
Furthermore, the core base.css file is also modified slightly:
- the TOC related statements have been removed
- some page breaking instructions are added
- the margins/padding of the page is set on a different HTML element, see the separate “overview” module for further details.
Some of the SVG files include a <!DOCTYPE, which leads to an error in epubcheck for EPUB 3.2. However, these are allowed in EPUB 3.3, and the errors may be safely ignored. The newer version of epubcheck accepts these
SVG files. (All EPUB Reading System work well with included <!DOCTYPE.)
Extract/add the right CSS references and gathers all resources (logo files, watermark image, etc.) to be added to the overall set of resources in the final book. Note that the HTML DOM of the main file is modified on the fly:
The reference to the core CSS is changed to base.css.
The background/watermark handling is stored in a separate, extra CSS file, whose reference is added to the document.
CSS files (for the 2021 version of the Process)
Handling CSS mappings is a bit complicated because the W3C setup is not entirely consistent...
In general, the HTML links to a style file of the sort
https://www.w3.org/StyleSheets/TR/2021/W3C-{specStatus}
. These files are all very simple: import a commonbase.css
file and add a setting for the background image using the logo file (this is, usually, the left stripe in the text). The logo used with the namehttps://www.w3.org/StyleSheets/TR/2021/logos/{specStatus}.svg
The references to the logo files use relative URL-s, which is just fine for the EPUB version. All these files must be copied into the zip file, and the HTML references must be changed to their relative equivalents.However… the complication, from EPUB's point of view, mostly for some older or rarely used specification versions. The complications may be:
2021
subtree of theStyleSheets/TR/
directory of the W3C siteThe function below handles the exceptional cases separately by storing some css and png files in a fixed place and copy the files from there (as opposed to using the W3C files directly). This is done instead of performing some extra CSS parsing.
Furthermore, the core
base.css
file is also modified slightly: - the TOC related statements have been removed - some page breaking instructions are added - the margins/padding of the page is set on a different HTML element, see the separate “overview” module for further details.Small note on the SVG Logo files
Some of the SVG files include a
<!DOCTYPE
, which leads to an error in epubcheck for EPUB 3.2. However, these are allowed in EPUB 3.3, and the errors may be safely ignored. The newer version of epubcheck accepts these SVG files. (All EPUB Reading System work well with included<!DOCTYPE
.)