Skip to main content

flm_core/stdlib/backends/
mod.rs

1//! Rendering: the standard backends, and what every backend
2//! shares — the presentation vocabulary, the lowering stage and the pieces
3//! stage.
4//!
5//! Rendering turns a frozen document into output bytes in ordinary pipeline
6//! stages. The terms below are used throughout this module and its
7//! submodules:
8//!
9//! - A **backend** is the registration bundle for one output format: the
10//!   elements its emitter writes natively, a lowering stage, an emit stage and
11//!   a final stage ([`BackendDef`](crate::core::registry::BackendDef)).
12//! - **Lowering** rewrites each frozen tree into a presentation tree for one
13//!   backend, by applying the lowering rule selected for each element, in
14//!   rounds, until only elements the backend writes natively remain; the
15//!   result is computed data in the table `flm.lowered.<backend>` (see
16//!   [backends, lowering, and
17//!   outputs](crate::guide::concepts_overview#backends-lowering-and-outputs)).
18//! - A **lowering rule** is a named registry entity written for one element:
19//!   it declares what it requires, reads and produces, and implements `Lower`,
20//!   which stages (builds into the lowered tree) the element's presentation
21//!   for one backend ([`LoweringRule`](crate::core::lowering::LoweringRule)).
22//! - A **presentation node** is a node of a **presentation element**, an
23//!   element that never occurs in a source document: lowering rules stage
24//!   such nodes, and every backend's emitter reads them. The presentation
25//!   elements every backend shares form the presentation vocabulary
26//!   ([`pres`]).
27//! - A **decoration** is a node whose element carries the
28//!   [`Decoration`](pres::Decoration) aspect (a run-in heading, a margin note,
29//!   a closing mark): the lowering driver moves it out of the content of the
30//!   presentation node that contains it into an attached slot of that node
31//!   (see [decorations, roles and
32//!   kinds](crate::guide::concepts_overview#decorations-roles-and-kinds)).
33//! - A **piece** is a document-level synthesized value that a backend places
34//!   before or after the document's content (the title, the list of
35//!   footnotes, the bibliography) ([`Piece`](crate::core::piece::Piece)).
36//! - A **node region** is one of a node's arguments or one of its slots
37//!   ([`NodeRegion`](crate::core::lowering::NodeRegion)); a lowering rule can
38//!   lower a node region of another node where its own node is placed. An
39//!   **output region** is a different thing: one named part of an output's
40//!   entry artifact, such as the document's content or one piece
41//!   ([`Regions`](crate::core::region::Regions)).
42//!
43//! After lowering, a backend's **emitter** (its emit stage) walks the lowered
44//! trees and writes the output's bytes, and its final stage (see [output
45//! regions and the final
46//! stage](crate::guide::concepts_overview#output-regions-and-the-final-stage))
47//! makes the artifacts from them.
48//!
49//! # Module map
50//!
51//! - [`pres`] — the presentation vocabulary: the presentation elements
52//!   (`flm.pres.*`), their typed payloads, and the functions an emitter reads
53//!   a presentation node with.
54//! - [`lowering`] — the lowering stage every backend registers, the driver
55//!   that runs the rounds over one tree and implements the
56//!   [`Lowerer`](crate::core::lowering::Lowerer) every rule works through, the
57//!   default rules of the structural elements, and the `lowering` feature.
58//! - [`pieces`] — the `pieces` feature and the pieces stage every backend that
59//!   places pieces registers.
60//! - [`text`] — the `text` backend: its native element set, its emitter over
61//!   the [layout engine](crate::layout), its emit and final stages, and the
62//!   `text` output and workflow.
63//! - [`latex`] — the LaTeX family: what every LaTeX backend shares — the
64//!   construct elements, escaping, the typed sink, the package requests and
65//!   definition pieces, and the style file.
66//! - [`latex_recomposed`] — the `latex-recomposed` backend: the document
67//!   written back as LaTeX from the trees without block structure, with a
68//!   style file holding the definitions and packages the recomposed LaTeX
69//!   needs.
70//! - [`latex_rendered`] — the `latex-rendered` backend: the document written
71//!   as fully resolved LaTeX for LuaLaTeX, one command or environment per
72//!   presentation element, with a style file defining them.
73//! - [`html`] — the `html` backend: the document written as an HTML page for
74//!   a browser.
75//!
76//! See also [the rendering guide](crate::guide::rendering).
77//!
78//! # Dependencies between backends and features
79//!
80//! This module is the only one in the crate that uses both
81//! [`crate::core::data`] and [`crate::layout`]; computed data and the layout
82//! engine do not depend on each other. No backend depends on a content
83//! feature (a feature that declares elements an author writes, such as
84//! headings or lists). A content feature may depend on a backend: it may
85//! write a lowering rule for that backend, mark that rule as the default on
86//! that backend ([`DefaultMark`](crate::core::lowering::DefaultMark)) after
87//! declaring the backend as a peer ([`FeatureBuilder::peer_backend`]), and
88//! read that backend's render options. Each standard feature's rule for the
89//! `latex-recomposed` backend does this.
90//!
91//! [`FeatureBuilder::peer_backend`]: crate::core::registry::FeatureBuilder::peer_backend
92
93pub mod html;
94pub mod latex;
95pub mod latex_recomposed;
96pub mod latex_rendered;
97pub mod lowering;
98pub mod pieces;
99pub mod pres;
100pub mod text;