Add a TeX page builder over vertical lists

This commit is contained in:
gloamxun committed 2026-10-23 01:41:06 +08:00
1 parent 49bd9b63e6
commit d4a9c6b4fd
6 files changed
+397 -7

No files matched your search

+1 -1
View File
@@ -583,7 +583,7 @@ execution, service and incrementality targets) is in
The first M7 service integration is available as `POST /api/route-d/preview`, with PDF export at `POST /api/route-d/pdf`.
It accepts blank-line-separated source with a small `\section`/`\textbf`/`\emph`/display-math/list subset, lays it out with the route-D page
builder, and returns the v1-compatible preview shape plus per-page hashes and
SVG. Route-D paragraphs are laid out with CMR10 advances, kerns and ligatures; runs of two or three hyphens become en/em dashes, the breaker follows TeX's `\pretolerance`/`\tolerance`/`\emergencystretch` passes with demerits (falling back to TeX's overfull fill when no feasible break exists), and the PDF `/W` array reports the same advances, so extracted text keeps word boundaries. Non-final lines bake their justification into the glue widths, so the PDF and the SVG preview are flush to the measure instead of showing natural spaces. Interline spacing follows TeX (`\baselineskip` unless `\lineskiplimit` forces `\lineskip`), and `Document::par_skip` adds `\parskip` between paragraph units. Embedded text fonts are subset per document to the glyphs actually used (retaining glyph IDs and composite components), and each subset carries a ToUnicode CMap covering its used characters. `Document::insertion_classes` caps each insertion class to a page fraction and defers overflow to the next page; `Document::insertion_skip` models `\skip\footins` once per page before the first insertion class, and `InsertionClass::skip` overrides it for one class. The v1 `/preview` and project APIs are unchanged and remain the default.
SVG. Route-D paragraphs are laid out with CMR10 advances, kerns and ligatures; runs of two or three hyphens become en/em dashes, the breaker follows TeX's `\pretolerance`/`\tolerance`/`\emergencystretch` passes with demerits (falling back to TeX's overfull fill when no feasible break exists), and the PDF `/W` array reports the same advances, so extracted text keeps word boundaries. Non-final lines bake their justification into the glue widths, so the PDF and the SVG preview are flush to the measure instead of showing natural spaces. Interline spacing follows TeX (`\baselineskip` unless `\lineskiplimit` forces `\lineskip`), and `Document::par_skip` adds `\parskip` between paragraph units. A standalone `page::PageBuilder` already selects page breaks by TeX's badness-plus-penalty cost, including glue setting, `\topskip` and `\maxdepth`; it is covered by unit tests and will replace the scrolling builder next. Embedded text fonts are subset per document to the glyphs actually used (retaining glyph IDs and composite components), and each subset carries a ToUnicode CMap covering its used characters. `Document::insertion_classes` caps each insertion class to a page fraction and defers overflow to the next page; `Document::insertion_skip` models `\skip\footins` once per page before the first insertion class, and `InsertionClass::skip` overrides it for one class. The v1 `/preview` and project APIs are unchanged and remain the default.
Project previews can opt into the new core with `POST /api/projects/{id}/preview?engine=route-d`; the same project preview without the query keeps the v1 pipeline. The web client exposes this as the `引擎: v1` / `引擎: Route-D` toggle in the preview toolbar; the choice is stored in `localStorage` and switches both the preview request and `POST /api/projects/{id}/pdf`, since the PDF handler honors the same `engine=route-d` query. Route-D project previews keep a session, so an unchanged source reports zero recomputed pages; text edits and structural edits with an unchanged paragraph prefix rebuild from the first difference through `Engine::relayout_from`, reusing the sealed pages before it, while edits without a reusable prefix fall back to a full layout. `POST /api/route-d/edit/{unit}` applies one paragraph edit to the last route-D
document and returns the same page list plus `changedPages` and
+1
View File
@@ -1,5 +1,6 @@
pub mod cmr10;
pub mod math;
pub mod page;
pub mod paragraph;
pub mod pdf;
pub mod render;
+371
View File
@@ -0,0 +1,371 @@
//! TeX-style page building over an explicit vertical list.
//!
//! This module is the foundation for the TeX page builder described by P2 of
//! `docs/ROUTE_D_PLAN.md`. Instead of stopping at the first box that does not
//! fit, it scores every candidate breakpoint with TeX's page badness and
//! penalty cost, so a fuller page can win over a much emptier one. Floats and
//! insertion classes are still handled by the incremental builder in
//! `Engine`; wiring this module into `Document` is the next P2 step.
use crate::Mark;
use std::cmp::Reverse;
/// Vertical glue with the stretch and shrink TeX uses to set a page.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct VerticalGlue {
pub width: i64,
pub stretch: i64,
pub shrink: i64,
}
impl VerticalGlue {
pub const fn new(width: i64, stretch: i64, shrink: i64) -> Self {
Self {
width,
stretch,
shrink,
}
}
}
/// Material that can appear in a vertical list handed to the page builder.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum VerticalNode {
Box { height: i64, depth: i64 },
Glue(VerticalGlue),
Penalty(i64),
Mark(Mark),
}
/// One page chosen by [`PageBuilder::build`].
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct PageFragment {
/// Index of the first node that belongs to this page.
pub start: usize,
/// Index one past the last node that belongs to this page.
pub end: usize,
/// TeX's page cost for the breakpoint: badness plus penalty.
pub cost: i64,
/// Badness of the page height against the page goal.
pub badness: i64,
/// Height of the page box after glue setting.
pub height: i64,
/// Depth of the page box, capped at `max_depth`.
pub depth: i64,
}
#[derive(Clone, Copy, Debug)]
struct Candidate {
cost: i64,
badness: i64,
height: i64,
depth: i64,
shrink: i64,
end: usize,
next: usize,
}
/// TeX page builder parameters (`\vsize`, `\topskip`, `\maxdepth`).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct PageBuilder {
pub page_goal: i64,
pub top_skip: i64,
pub max_depth: i64,
}
impl PageBuilder {
pub const fn new(page_goal: i64) -> Self {
Self {
page_goal,
top_skip: 0,
max_depth: 0,
}
}
/// Split `nodes` into pages, choosing the cheapest legal break each time.
pub fn build(&self, nodes: &[VerticalNode]) -> Vec<PageFragment> {
let mut pages = Vec::new();
let mut start = self.skip_leading(nodes, 0);
while start < nodes.len() {
let Some((fragment, next)) = self.best_fragment(nodes, start) else {
break;
};
let next = next.max(start + 1);
pages.push(fragment);
start = self.skip_leading(nodes, next);
}
pages
}
fn skip_leading(&self, nodes: &[VerticalNode], mut index: usize) -> usize {
while index < nodes.len() {
match nodes[index] {
VerticalNode::Glue(_) | VerticalNode::Penalty(_) => index += 1,
_ => break,
}
}
index
}
fn best_fragment(&self, nodes: &[VerticalNode], start: usize) -> Option<(PageFragment, usize)> {
let mut height = 0_i64;
let mut stretch = 0_i64;
let mut shrink = 0_i64;
let mut depth = 0_i64;
let mut first_box = true;
let mut candidates: Vec<Candidate> = Vec::new();
for index in start..nodes.len() {
match &nodes[index] {
VerticalNode::Box {
height: box_height,
depth: box_depth,
} => {
let contribution = if first_box {
(*box_height).max(self.top_skip)
} else {
*box_height
};
height += contribution;
depth = *box_depth;
first_box = false;
}
VerticalNode::Glue(glue) => {
if index > start {
candidates.push(self.candidate(height, depth, stretch, shrink, 0, index));
}
height += glue.width;
stretch += glue.stretch.max(0);
shrink += glue.shrink.max(0);
}
VerticalNode::Penalty(penalty) => {
if *penalty <= -10_000 {
let end = index.max(start);
let badness = self.badness(height, stretch, shrink);
let fragment =
self.fragment(start, end, height, depth, badness, badness + penalty);
return Some((fragment, index + 1));
}
if index > start {
candidates
.push(self.candidate(height, depth, stretch, shrink, *penalty, index));
}
}
VerticalNode::Mark(_) => {}
}
}
candidates.push(self.candidate(height, depth, stretch, shrink, 0, nodes.len()));
let best = self.select(candidates)?;
let fragment = self.fragment(
start,
best.end,
best.height,
best.depth,
best.badness,
best.cost,
);
Some((fragment, best.next))
}
fn candidate(
&self,
height: i64,
depth: i64,
stretch: i64,
shrink: i64,
penalty: i64,
end: usize,
) -> Candidate {
let depth = depth.max(0);
let (height, depth) = if depth > self.max_depth {
(height + depth - self.max_depth, self.max_depth)
} else {
(height, depth)
};
let badness = self.badness(height, stretch, shrink);
Candidate {
cost: badness + penalty,
badness,
height,
depth,
shrink,
end,
next: end + 1,
}
}
fn badness(&self, height: i64, stretch: i64, shrink: i64) -> i64 {
if height == self.page_goal {
return 0;
}
let (shortfall, slack) = if height < self.page_goal {
(self.page_goal - height, stretch)
} else {
(height - self.page_goal, shrink)
};
if slack <= 0 {
return 10_000;
}
let ratio = shortfall as f64 / slack as f64;
let badness = 100.0 * ratio * ratio * ratio;
if badness >= 10_000.0 {
10_000
} else {
badness.round() as i64
}
}
fn fragment(
&self,
start: usize,
end: usize,
height: i64,
depth: i64,
badness: i64,
cost: i64,
) -> PageFragment {
PageFragment {
start,
end,
cost,
badness,
height,
depth,
}
}
fn select(&self, candidates: Vec<Candidate>) -> Option<Candidate> {
let feasible: Vec<Candidate> = candidates
.iter()
.copied()
.filter(|candidate| {
candidate.height <= self.page_goal
|| candidate.height - self.page_goal <= candidate.shrink
})
.collect();
let pool = if feasible.is_empty() {
candidates
} else {
feasible
};
pool.into_iter()
.min_by_key(|candidate| (candidate.cost, Reverse(candidate.height)))
}
}
#[cfg(test)]
mod tests {
use super::*;
fn box_(height: i64, depth: i64) -> VerticalNode {
VerticalNode::Box { height, depth }
}
fn glue(width: i64, stretch: i64, shrink: i64) -> VerticalNode {
VerticalNode::Glue(VerticalGlue::new(width, stretch, shrink))
}
#[test]
fn breaks_before_the_page_overflows() {
let builder = PageBuilder::new(100);
let nodes = vec![
box_(40, 0),
glue(0, 10, 0),
box_(40, 0),
glue(0, 10, 0),
box_(40, 0),
];
let pages = builder.build(&nodes);
assert_eq!(
pages.iter().map(|page| page.height).collect::<Vec<_>>(),
vec![80, 40]
);
assert_eq!(pages[0].badness, 800);
}
#[test]
fn glue_stretch_can_fill_the_page_exactly() {
let builder = PageBuilder::new(100);
let nodes = vec![box_(50, 0), glue(0, 10, 0), box_(50, 0)];
let pages = builder.build(&nodes);
assert_eq!(pages.len(), 1);
assert_eq!(pages[0].height, 100);
assert_eq!(pages[0].badness, 0);
}
#[test]
fn forced_penalty_breaks_the_page() {
let builder = PageBuilder::new(100);
let nodes = vec![box_(30, 0), VerticalNode::Penalty(-10_000), box_(30, 0)];
let pages = builder.build(&nodes);
assert_eq!(
pages.iter().map(|page| page.height).collect::<Vec<_>>(),
vec![30, 30]
);
}
#[test]
fn penalty_can_move_the_break_to_an_earlier_page() {
let nodes = |penalty| {
vec![
box_(40, 0),
glue(0, 10, 0),
box_(40, 0),
VerticalNode::Penalty(penalty),
box_(40, 0),
]
};
let calm = PageBuilder::new(100).build(&nodes(0));
assert_eq!(
calm.iter().map(|page| page.height).collect::<Vec<_>>(),
vec![80, 40]
);
let penalized = PageBuilder::new(100).build(&nodes(9_500));
assert_eq!(
penalized.iter().map(|page| page.height).collect::<Vec<_>>(),
vec![40, 80]
);
}
#[test]
fn top_skip_sets_the_first_box_height() {
let mut builder = PageBuilder::new(100);
builder.top_skip = 10;
let nodes = vec![box_(5, 0), glue(0, 0, 0), box_(5, 0)];
let pages = builder.build(&nodes);
assert_eq!(pages.len(), 1);
assert_eq!(pages[0].height, 15);
}
#[test]
fn max_depth_moves_excess_depth_into_the_height() {
let mut builder = PageBuilder::new(100);
builder.max_depth = 4;
let pages = builder.build(&[box_(90, 10)]);
assert_eq!(pages[0].height, 96);
assert_eq!(pages[0].depth, 4);
}
#[test]
fn marks_do_not_change_page_heights() {
let builder = PageBuilder::new(100);
let nodes = vec![
VerticalNode::Mark(Mark {
class: 0,
text: "intro".to_owned(),
}),
box_(30, 0),
VerticalNode::Mark(Mark {
class: 0,
text: "next".to_owned(),
}),
glue(0, 0, 0),
box_(30, 0),
];
let pages = builder.build(&nodes);
assert_eq!(pages.len(), 1);
assert_eq!(pages[0].height, 60);
assert_eq!((pages[0].start, pages[0].end), (0, 5));
}
}
-1
View File
@@ -824,7 +824,6 @@ pub fn layout_items(items: &[HorizontalItem], style: &ParagraphStyle) -> Paragra
.collect();
let extents: Vec<(i64, i64)> = lines.iter().map(|line| line_extent(line)).collect();
let mut line_baselines = Vec::with_capacity(extents.len());
let mut height = 0;
if let Some((first_ascent, _)) = extents.first().copied() {
let mut baseline = first_ascent;
line_baselines.push(baseline);
+15 -2
View File
@@ -61,8 +61,11 @@ Known gaps, in dependency order:
`\looseness`, and `\baselineskip`/`\lineskip`/`\parskip` interline
glue), but not yet custom `\sfcode` overrides, generic `fil`/`fill` glue
orders or `\prevgraf`;
2. the page builder is a scrolling builder with fraction policies, not a TeX
page builder with badness and an interpreted `\output`;
2. the page builder used by `Document` is still the scrolling builder with
fraction policies; `page::PageBuilder` now implements the candidate-breakpoint
cost model (badness + penalty, glue setting, `\topskip`, `\maxdepth`) with
unit tests, but it is not yet wired into `Document` and an interpreted
`\output` is absent;
3. `\insert` classes are data structures, not TeX registers and an output
routine;
4. `\halign` handles spans/omit/templates but not the full TeX column algorithm;
@@ -231,6 +234,16 @@ Scope:
- floats: TeX-compatible policy module used by the default output routine
(top/bottom fractions and counts already exist).
The foundation is in `crates/texrra-tex-core/src/page.rs`: `PageBuilder` takes a
`VerticalNode` list (box height/depth, glue width/stretch/shrink, penalties,
marks) and chooses each page at the cheapest feasible breakpoint, scoring
badness from the page goal and accumulated glue, adding the break penalty, and
applying `\topskip` to the first box and `\maxdepth` to the page depth. Seven
unit tests cover overfull avoidance, exact glue filling, forced penalties,
penalty-driven earlier breaks, `\topskip`, `\maxdepth` and marks. Wiring this
builder into `Document` and replacing the scrolling path is the next step,
followed by `\voffset`, insertion registers and the interpreted `\output`.
Acceptance: 10 page fixtures (article text, footnotes, floats, forced breaks);
page counts identical and first/last baselines within 1pt of pdfLaTeX.
+9 -3
View File
@@ -110,7 +110,7 @@ and justification.
| --- | --- | --- |
| M0 | vertical list, page builder, checkpoint, page hash, edit demo | edit on page 2 rebuilds only page 2 |
| M1 | TeX box/glue/penalty + paragraph builder (`\par`, `\hsize`, `\parindent`) | **partial**: item stream, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing, `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 100-240pt plus register, geometry and vertical-glue fixtures; custom `\sfcode`, generic fil glue and `\prevgraf` next |
| M2 | page builder + `\output`, `\vsize`, `\topskip`, footnotes, floats | **partial**: `\vsize` page goal, `\topskip`, forced penalties, `Insertion` reserve, running `Mark`s, `OutputRoutine` hook, top/bottom `Float` placement; interpreted `\output`, float pages next |
| M2 | page builder + `\output`, `\vsize`, `\topskip`, footnotes, floats | **partial**: `\vsize` page goal, `\topskip`, forced penalties, `Insertion` reserve, running `Mark`s, `OutputRoutine` hook, top/bottom `Float` placement; `page::PageBuilder` now scores candidate breakpoints with TeX page badness, glue setting, `\topskip`/`\maxdepth`, but is not yet wired into `Document`; interpreted `\output` next |
| M3 | `\halign`, `\omit`, `\span`, `\multispan`, booktabs/longtable | **partial**: source parsing, natural column widths, spans, rule rows, 10pt display-list painting and row-level page splitting; no booktabs/longtable parity yet |
| M4 | math lists, scripts, fractions, radicals, accents, delimiters | **partial**: token parser, atom boxes with CMR10 metrics, delimiter scaling, accents and a display-list painter; no CMEX size variants or TeX math spacing classes yet |
| M5 | NFSS/TFM metrics, CM/Latin Modern | same line/page breaks as reference |
@@ -270,7 +270,7 @@ for a later overlaid slash.
| --- | --- | --- |
| M0 checkpoint engine | done | page list, page hashes, snapshot/restore, edit replay |
| M1 horizontal/paragraphs | partial | boxes/glue/penalties, CMR10 metrics, TeX Live en-US hyphenation, TeX demerits and tolerance passes, `\hangindent`/`\parshape`, `\parfillskip`, sentence spacing (`\sfcode`/`\frenchspacing`), `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfTeX oracle matrix 100-240pt plus register, geometry and vertical-glue fixtures |
| M2 vertical/page builder | partial | vsize, topskip, insertions, marks, Rust output hook, top/bottom floats, float-page/text fractions, rules, vskip, penalties; interpreted `\output` absent |
| M2 vertical/page builder | partial | vsize, topskip, insertions, marks, Rust output hook, top/bottom floats, float-page/text fractions, rules, vskip, penalties; `page::PageBuilder` scores breakpoints with page badness and penalties and models `\topskip`/`\maxdepth`, but the document builder still uses the scrolling path; interpreted `\output` absent |
| M3 halign | partial | natural columns, spans, omit, hline rows, templates, noalign skip, rules; no PDF painter |
| M4 math | partial | atoms, scripts, fractions, roots, delimiters, accents, operators, classes, braces, boxed, negated; no math painter/shrink wrapping |
| M5 NFSS/TFM | partial | runtime `cmr10.tfm` widths/heights/depths/kern pairs and ff/fi/fl/ffi/ffl ligatures; text faces embed Liberation Serif/Mono as Type0 CID fonts with Identity-H, ToUnicode and width arrays; used faces embed per-document TrueType glyf subsets that keep the original glyph IDs, include composite components, and carry a matching ToUnicode CMap; ASCII documents use the compact tier; no Base-14 dependency; SVG carries family/weight/style |
@@ -299,7 +299,7 @@ M5 (partial): display-list text carries `FontFace::{Roman,Bold,Italic,BoldItalic
M6 (partial): `DisplayItem::Image` becomes a PDF XObject; `DisplayItem::Link` becomes `/Annots /Subtype /Link /URI`; `DisplayItem::Special` injects raw content-stream operators. SVG previews show images as grey rectangles and specials as comments.
M2 (partial): `Page::display_list_with_goal(page_goal)` places insertion material at `page_goal - insertion_height`, adds a 0.4pt separator above footnotes, splits oversized insertions at item boundaries, and paints top/bottom floats from their vertical `content` at the page edges; empty floats keep a dimension rectangle. Floats also size themselves from content, respect `text_fraction_percent`, respect `top_fraction_percent` (TeX `\topfraction`, default 70%) and `bottom_fraction_percent` (TeX `\bottomfraction`, default 30%), and can take a dedicated float page. The incremental edit path applies the same float fractions, float number limits, insertion-class limits and per-class `skip` rules as full layout. `Document::float_sep` (TeX `\floatsep`, default 12pt) reserves a gap between stacked floats of the same placement in both paths. `Document::text_float_sep` (TeX `\textfloatsep`, default 20pt) reserves exactly one gap between the float block and the body text on a page that has both, again in both paths; `Page::display_list_with_layout(page_goal, text_float_sep)` applies the same gap when rendering, while `display_list_with_goal` stays gap-free for callers that do not know the document settings. Float material at the top of a page starts at the top margin: `\topskip` is consumed only by body text, matching TeX float pages. `FloatPlacement::Here` models `[h]` floats: they keep their place in the body flow with `Document::in_text_sep` (TeX `\intextsep`, default 12pt) above and below, move to the next page when they do not fit, and count against `\totalnumber`. The page stores the float's `gap_after` so the display list advances the flow by the same amount the builder reserved.
M2 (partial): `Page::display_list_with_goal(page_goal)` places insertion material at `page_goal - insertion_height`, adds a 0.4pt separator above footnotes, splits oversized insertions at item boundaries, and paints top/bottom floats from their vertical `content` at the page edges; empty floats keep a dimension rectangle. Floats also size themselves from content, respect `text_fraction_percent`, respect `top_fraction_percent` (TeX `\topfraction`, default 70%) and `bottom_fraction_percent` (TeX `\bottomfraction`, default 30%), and can take a dedicated float page. The incremental edit path applies the same float fractions, float number limits, insertion-class limits and per-class `skip` rules as full layout. `Document::float_sep` (TeX `\floatsep`, default 12pt) reserves a gap between stacked floats of the same placement in both paths. `Document::text_float_sep` (TeX `\textfloatsep`, default 20pt) reserves exactly one gap between the float block and the body text on a page that has both, again in both paths; `Page::display_list_with_layout(page_goal, text_float_sep)` applies the same gap when rendering, while `display_list_with_goal` stays gap-free for callers that do not know the document settings. Float material at the top of a page starts at the top margin: `\topskip` is consumed only by body text, matching TeX float pages. `FloatPlacement::Here` models `[h]` floats: they keep their place in the body flow with `Document::in_text_sep` (TeX `\intextsep`, default 12pt) above and below, move to the next page when they do not fit, and count against `\totalnumber`. The page stores the float's `gap_after` so the display list advances the flow by the same amount the builder reserved. A standalone `page::PageBuilder` implements TeX's candidate-breakpoint cost model (page badness from accumulated glue stretch/shrink plus break penalties, `\topskip` for the first box, `\maxdepth` depth shifting) with seven unit tests; migrating `Document` onto it is the next P2 step.
M3 (partial): `Unit::halign` normalizes column widths, intercolumn gaps, row heights and cell text widths to scaled points; the painter uses 10pt glyphs in 12pt rows. Rules and spans are painted; tall tables split at row boundaries (`Halign::split_for_height`) with column widths preserved.
@@ -341,6 +341,12 @@ deliberately open rather than approximated:
or without `fil`, `\looseness`, `\baselineskip`/`\lineskip`/`\parskip`
interline glue, and the default `\sfcode`/`\frenchspacing` sentence spacing
are modelled.
- **M2**: the scrolling builder still drives `Document`; `page::PageBuilder`
implements TeX's candidate-breakpoint cost (badness + penalty, glue
stretch/shrink, `\topskip`, `\maxdepth`) and is covered by unit tests, but
migrating `Document` onto it, `\voffset`, insertion registers
(`\count`/`\dimen`/`\skip` per class) and an interpreted `\output` remain
open.
- **M5**: `cmr10.tfm` is parsed at runtime with widths, glyph heights/depths and kern pairs. only used text faces embed Liberation Serif/Mono as Type0/Identity-H; each face is subset to the glyphs actually used (composite components included, glyph IDs retained); FontFile2 and ToUnicode streams use Flate compression; the ToUnicode CMap follows the used characters; ff/fi/fl/ffi/ffl ligatures come from TFM, and CMR10 italic corrections are applied at line ends; full NFSS family switching is not implemented.
- **M6**: `\output`, `\insert`, mark/float output policies, class-file execution and
math limit policies are only partially modeled; `OutputRoutine::wants_break` can force a page break between units, and insertion material is stacked by class from the page bottom; `\output` is still Rust code rather than interpreted tokens.