Skip to main content

Module feature

Module feature 

Source
Expand description

The html feature: registers the HTML backend, its render options, the html output and the html workflow, and declares the four names the rest of the library uses to refer to them.

The html feature (FlmFeature), implemented by HtmlBackend and obtained with feature(), registers:

  • the construct element flm.pres.html.tag, one HTML tag as a node of the lowered tree;
  • the seven stylesheets and the formula renderer’s script that the backend ships, the definitions table flm.html.definitions and the stage that writes it (super::defs);
  • the tables the backend’s stages write: the lowered trees (flm.lowered.html), the HTML of each tree (flm.output.html), the page’s artifact set (flm.output.html.document) with its capability flm.output.html.singlefile, the artifact table flm.output.html.artifacts that the final stage reads, the lowered pieces (the document-level values a backend places beside the content, such as the title; Piece) (flm.lowered.html.pieces), the HTML of each piece (flm.output.html.pieces) and the regions (flm.output.html.regions);
  • the stage that builds the lowered pieces (PiecesStage for the html backend), the stage flm.html.emit-pieces and the regions stage flm.html.regions;
  • the backend’s regions output (RegionsOutput), contributed to the service slot flm.output.regions, so that a host’s own page assembler can find the regions;
  • the backend itself, with its native element set and its three stages (super::stages::stages);
  • the html output and the html workflow.

The render options are HtmlRenderOptions, declared with the feature’s settings under the feature name html, and HtmlAllowedUrlSchemes, the URL schemes the page may reference, which the feature declares beside its settings so that only Rust code sets it (who decides which schemes are allowed). The backend’s name is the base of the names of its stages (flm.html.*) and of its lowered-trees table (flm.lowered.html). The identifiers of the conditions it reports (flm.html.*) take the feature’s name, FEATURE_NAME, which is also html.

A future HTML output, such as a multi-file one, is meant to add a second final stage to this backend rather than a backend of its own. A feature of another crate whose lowering rule stages an HTML tag node (builds it into the lowered tree; see Lowerer) declares the construct element through a peer declaration (PeerName, FeatureBuilder::peer_element) instead of depending on this feature.

§The elements the backend writes natively

The native set (native_elements) holds 29 elements: every element of the presentation vocabulary, the construct element flm.pres.html.tag, and the six structural elements of FLOW_THROUGH that the backend emits natively, without a lowering rule, because they carry nothing an HTML page has to translate: flm.text, flm.group, flm.opaque-wrapper, flm.comment, flm.container and flm.parbreak.

The native set holds no element another feature owns, and in particular not the reference element flm.ref. The refs feature’s own lowering rule for flm.ref is therefore selected, and because that rule reads the resolved references, the plan schedules the stage that resolves them and, before it, the stage that computes the anchors. A heading then reaches the emitter with the anchor that becomes its id. In a registry without the refs feature, a heading carries no anchor and therefore no id, as on every other backend.

This backend needs the same tree state as the text backend (blocks structured, user definitions expanded), so one plan serves both, and a request for the text and the html outputs together is one run. A request for html and latex-recomposed together is refused, as one for text and latex-recomposed is, because those backends need different tree states.

§What the html workflow demands

The html workflow lists the html output and also demands (asks the plan for a stage that provides; PlanRequest::demand) the capability flm.validated, which the document’s checks provide together, so that every workflow runs the same checks over a document. The check feature (check_feature) declares that capability, so a registry that holds this backend must hold the check feature too.

See the module documentation for the backend as a whole.

Structs§

HtmlBackend
The html feature, which registers the HTML backend: its construct element, its definitions, its tables, its render options, its stages, the html output and the html workflow (the module documentation lists them).
HtmlRenderOptions
The render options of the HTML backend: the page’s title and language, the source-position attribute, the stop after a run-in heading, how stylesheets and scripts are delivered, the stylesheets and scripts the host adds to the page, how headings are tagged, and the heading level written as <h1>.

Enums§

DefinitionOverride
The delivery of a style or script definition: how the definition reaches the page.

Constants§

BACKEND
The backend’s name, html.
DEFAULT_TITLE
The title a page carries when neither the document nor the render request gives one: FLM document (HtmlRenderOptions::title).
FEATURE_NAME
The feature’s registered name, html. It is also the middle part of the identifiers of the conditions this backend reports, flm.html.*, and the name under which the feature’s settings are declared.
FLOW_THROUGH
The six structural elements the HTML backend emits natively, without a lowering rule, beside the presentation vocabulary and the construct element: text, groups, opaque wrappers, source comments, containers and paragraph breaks (see the module documentation).
OUTPUT
The html output’s name.
WORKFLOW
The html workflow’s name.

Functions§

feature
Returns the html feature (HtmlBackend) as a shared value, ready to be listed in a package entry.
native_elements
Returns the backend’s native element set, the elements its emitter writes without a lowering rule: every element of the presentation vocabulary (pres::ALL), the construct element flm.pres.html.tag, then the elements of FLOW_THROUGH, in that order (29 elements).