Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/css2016"

Handling CSS mappings is a bit complicated because the W3C setup is not entirely consistent...

The general, and "usual", case is that the specStatus value, i.e., 'REC', 'WD', 'CR', etc, means that there is a logo used with the name https://www.w3.org/StyleSheets/TR/2016/logos/{specStatus}.svg (this is, usually, the left stripe in the text). Structurally, the HTML links to a style file of the sort https://www.w3.org/StyleSheets/TR/2016/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. 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, is that

  • The logo references in those CSS files are usually absolute URL-s (but not always). If the original structure was followed, the CSS file should be changed on-the-fly (when put into the zip file) changing the URL reference. This would involve an extra CSS parsing.
  • The structure described above has exceptions. Sometimes there is no such logo (e.g., for the "basic" document, or the living documents), sometimes logos are shared (e.g., FPWD and WD), i.e., their name cannot simply deduced from the value of specStatus and, in some cases, an extra trick is used to create a watermark using a separate image file.
  • The logo file URL-s rely on content negotiations to choose between SVG and PNG. This does not work for the EPUB content; SVG files are preferred.

The approach chosen to convert the content to the EPUB file is therefore as follows:

  • The core reference in the HTML file is changed to a (stable) base.css file. This file is copied into the EPUB file from a separate, but fixed, URI]. This is a modified version of the "real" base.css with:
    • 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.
  • An extra css file is created, stored in the in the EPUB file and referred to from the resulting HTML file, setting the right background with a relative URL. This is done by using a simple template, which is imply a copy of the relevant template on the W3C site.
    • In some cases the template is more complex (e.g., CG or BG documents due to different logo sizes) and may also include a watermark. Luckily, the watermark is always the same file, which simplifies things somewhat.

The easy (i.e., well structured) cases are assembled in the specStatus_simple array; these can be handled automatically. The characteristics of "non-standard" cases (e.g., BG/CG documents) are described in the specStatus_css object, based on the specStatus_css_mappings interface.

Index

Variables

Const specStatus_simple

specStatus_simple: string[] = ['ED', 'WD', 'CR', 'CRD', 'PR', 'LD', 'LS', 'PER', 'REC', 'RSCND', 'OBSL', 'SPSD',]

specStatus values with a common, 'standard' behavior: distinct logos based on value, no watermark, simple background template

Functions

extract_css

  • 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.

    Parameters

    Returns ResourceRef[]

    • list of extracted additional resources

Object literals

Const specStatus_css

specStatus_css: object

Mapping from specStatus to its relevant description for the cases when a simple, automatic mapping is not possible. See specStatus_css_mappings for the definition of the terms.

Note that the following spec status values do not have an entry (nor do they appear in specStatus_simple): base, BG-DRAFT, BG-FINAL, and CG-FINAL. This is deliberate: for the BG/CG documents the TR style has a big logo on the left at the top of the TOC column, something that is unnecessary for the EPUB case where that TOC column is non-existent altogether; on the other hand, it leads to a narrower content that is detrimental in many reading systems. (CG-DRAFT has a watermark, hence its presence.) As for thebase` value, there is no logo or other style addition altogether.

CG-DRAFT

CG-DRAFT: object

logo_media_type

logo_media_type: string = common.media_types.png

logo_name

logo_name: null = null

special_template

special_template: string = cg_draft_template

watermark

watermark: true = true

FPWD

FPWD: object

logo_name

logo_name: string = "WD.svg"

watermark

watermark: false = false

FPWD-NOTE

FPWD-NOTE: object

logo_name

logo_name: string = "WG-Note.svg"

watermark

watermark: false = false

LC

LC: object

logo_name

logo_name: string = "WD.svg"

watermark

watermark: false = false

UNOFFICIAL

UNOFFICIAL: object

logo_media_type

logo_media_type: string = common.media_types.png

logo_name

logo_name: string = "UD.png"

special_template

special_template: string = undefined_template

watermark

watermark: true = true

WG-NOTE

WG-NOTE: object

logo_name

logo_name: string = "WG-Note.svg"

watermark

watermark: false = false