Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "lib/common"

Index

Variables

Let TR_css_files

TR_css_files: string

Base URL for the official W3C css files (only the non-SVG ones are used directly).

Let TR_logo_files

TR_logo_files: string

Base URL for the official W3C logos (only the non-SVG ones are used directly).

Const W3C_icons

W3C_icons: "https://www.w3.org/Icons/" = "https://www.w3.org/Icons/"

Generic ICON directory on the W3C site

Const acceptable_url_endings

acceptable_url_endings: string[] = ['/','.html','.xhtml','.json',]

Acceptable endings for document URL-s. We try to avoid cases when the relative URL calculations go wrong

Const entity_codes

entity_codes: string[][] = [[' ', ' '],['<', '<'],['>', '>'],['"', '"'],[''', '''],['®', '®'],['£', '£'],['¥', '¥'],['€', '€'],['¢', '¢'],['—', '—'],['–', '–'],[' ', ' '],[' ', ' '],[' ',' '],]

Entity/code pairs: the XHTML conversion is supposed to remove the XML entities (if used) to their code alternatives.

The table is not exhaustive, of course, but contains the most frequently used characters in specifications.

Let fixup_js

fixup_js: string

Generic 'fixup' script (used for warnings for rescinded or obsolete versions).

Const invalid_host_names

invalid_host_names: string[] = ['127.0.0.1', '127.254.1.2', '10.1.2.3', '10.254.4.5','172.16.1.2', '172.31.4.5', '192.168.0.1', '192.168.254.5','fe80::1', 'fe80:ffff::ffff', 'localhost', 'ip6-localhost',]

Invalid host names (essentially "localhost" and friends); unless explicitly set in the environment, these are considered to be unsafe. This is important for server deployment.

Const is_browser

is_browser: boolean = (process === undefined || process.title === 'browser')

Flag to decide whether the code runs in a browser or in node.js

Const local_icons

local_icons: "Icons/" = "Icons/"

Const local_port_number

local_port_number: "80" = "80"

Default port number for the server locally. Set to the default HTTP port number; the environment variable PORT may, however, overwrite this for a server.

Let local_style_files

local_style_files: string

Local (relative) URL for styles and logos

Let modified_epub_files

modified_epub_files: string

Base URL for the W3C files (like base.css, logos in SVG format) modified for EPUB.

Const process_2021_date

process_2021_date: "2021-11-02" = "2021-11-02"

Let process_version

process_version: number

Process version being used

Const spec_generator

spec_generator: "https://labs.w3.org/spec-generator/?type=respec&url=" = "https://labs.w3.org/spec-generator/?type=respec&url="

URL of the spec generator service, used if the source has to be transformed via respec first.

Const spec_status_values

spec_status_values: string[] = ['base','MO','unofficial','ED','FPWD','WD','LC','LD','LS','CR','CRD','PR','PER','REC','RSCND','STMT','DNOTE','FPWD-NOTE','NOTE','WG-NOTE','BG-DRAFT','BG-FINAL','CG-DRAFT','CG-FINAL','Member-SUBM','draft-finding','editor-draft-finding','finding',]

Valid Spec Status values

Const text_content

text_content: string[] = [media_types.css,media_types.text,media_types.es,media_types.html,media_types.js,media_types.json,media_types.jsonld,media_types.svg,media_types.xhtml,]

These media types refer to textual content, no reason to bother about streaming when fetching them...

Const tr_epub_css

tr_epub_css: "body {/* Layout */max-width: 50em; /* limit line length to 50em for readability */margin: 0 auto !important; /* center text within page, space for footers */padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag */}div[role~="main"] {margin: 0 auto; /* center text within page */max-width: none;padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag */}body {max-width: 100% !important;}h2 {page-break-before: always;page-break-inside: avoid;page-break-after: avoid;}div.head h2 {page-break-before: auto;page-break-inside: avoid;page-break-after: avoid;}figure {page-break-inside: avoid;}h3, h4, h5 {page-break-after: avoid;}dl dt {page-break-after: avoid;}dl dd {page-break-before: avoid;}div.example, div.note, pre.idl, .warning, table.parameters, table.exceptions {page-break-inside: avoid;}p {orphans: 4;widows: 2;}.outdated-warning {position: absolute;border-style: solid;border-color: red;}.outdated-warning input {display: none;}p.copyright,p.copyright small { font-size: small; }#toc-nav, #toc-toggle-inline {display:none !important;}#back-to-top, .toc-toggle {display: none !important;}nav#toc {display: none}" = `body {/* Layout */max-width: 50em; /* limit line length to 50em for readability */margin: 0 auto !important; /* center text within page, space for footers */padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag */}div[role~="main"] {margin: 0 auto; /* center text within page */max-width: none;padding: 1.6em 1.5em 2em 50px; /* assume 16px font size for downlevel clients */padding: 1.6em 1.5em 2em calc(26px + 1.5em); /* leave space for status flag */}body {max-width: 100% !important;}h2 {page-break-before: always;page-break-inside: avoid;page-break-after: avoid;}div.head h2 {page-break-before: auto;page-break-inside: avoid;page-break-after: avoid;}figure {page-break-inside: avoid;}h3, h4, h5 {page-break-after: avoid;}dl dt {page-break-after: avoid;}dl dd {page-break-before: avoid;}div.example, div.note, pre.idl, .warning, table.parameters, table.exceptions {page-break-inside: avoid;}p {orphans: 4;widows: 2;}.outdated-warning {position: absolute;border-style: solid;border-color: red;}.outdated-warning input {display: none;}p.copyright,p.copyright small { font-size: small; }#toc-nav, #toc-toggle-inline {display:none !important;}#back-to-top, .toc-toggle {display: none !important;}nav#toc {display: none}`

Extra CSS file for EPUB content; mainly used to adapt and, possibly, to compensate the effects of the main CSS file. The features are

  1. Due to the problems with Apple Books, the target DOM is modified by adding an extra div element, which carries the padding statements. Books does not understand a padding and margin on the body element, hence this addition...
  2. A number of page break control added to header elements, definition lists, or figure elements (even if, at this time, not many reading systems really honer these...)
  3. The outdated warning boxes are stuck to the bottom, instead coming up with interaction
  4. The table of content, as generated into the file, is removed (via a display attribute); its content is put into a separate navigation file used by the reading system.

Const wcag_checked

wcag_checked: string[] = ['REC','WG-NOTE','IG-NOTE','NOTE','finding',]

Document types that are supposed to be WCAG A level due to the W3C publication check.

Object literals

Const CORS_headers

CORS_headers: object

CORS headers to be added to the server response

Access-Control-Allow-Headers

Access-Control-Allow-Headers: string = allow_headers.join(',')

Access-Control-Allow-Methods

Access-Control-Allow-Methods: string = allow_methods.join(',')

Access-Control-Allow-Origin

Access-Control-Allow-Origin: string = "*"

Access-Control-Expose-Headers

Access-Control-Expose-Headers: string = expose_headers.join(',')

Const media_types

media_types: object

Various media types used in the code.

css

css: string = "text/css"

epub

epub: string = "application/epub+zip"

es

es: string = "text/ecmascript"

html

html: string = "text/html"

js

js: string = "text/javascript"

json

json: string = "application/json"

jsonld

jsonld: string = "application/ld+json"

png

png: string = "image/png"

svg

svg: string = "image/svg+xml"

text

text: string = "text/plain"

xhtml

xhtml: string = "application/xhtml+xml"