Support classed marks in the output routine
This commit is contained in:
1 parent
91171f2a90
commit
a93200cbfb
4 files changed
+76
-34
No files matched your search
@@ -1524,7 +1524,7 @@ struct PagedOutput {
|
||||
skips: [i64; 256],
|
||||
initial_dimens: Vec<(u8, i64)>,
|
||||
initial_skips: Vec<(u8, i64)>,
|
||||
pending_marks: Vec<String>,
|
||||
pending_marks: Vec<(u8, String)>,
|
||||
}
|
||||
|
||||
impl PagedOutput {
|
||||
@@ -2196,7 +2196,7 @@ impl Engine {
|
||||
let mut pages = Vec::new();
|
||||
let mut held: BTreeMap<u8, Vec<VerticalItem>> = BTreeMap::new();
|
||||
let mut fragments = builder.build_with_deferred_bottom_floats(&nodes);
|
||||
let mut carried_marks: Vec<String> = Vec::new();
|
||||
let mut carried_marks: Vec<(u8, String)> = Vec::new();
|
||||
let mut page_index = 0;
|
||||
while page_index < fragments.len() {
|
||||
let fragment = fragments[page_index].clone();
|
||||
@@ -2279,7 +2279,7 @@ impl Engine {
|
||||
if !carried_marks.is_empty() {
|
||||
let mut marks_with_carry: Vec<Mark> = std::mem::take(&mut carried_marks)
|
||||
.into_iter()
|
||||
.map(|text| Mark { class: 0, text })
|
||||
.map(|(class, text)| Mark { class, text })
|
||||
.collect();
|
||||
marks_with_carry.append(&mut marks);
|
||||
marks = marks_with_carry;
|
||||
@@ -3484,6 +3484,24 @@ mod tests {
|
||||
assert_eq!(engine.layout.pages[1].marks[0].class, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_marks_carry_their_class() {
|
||||
let mut units = Vec::new();
|
||||
for step in 0..3_u64 {
|
||||
units.push(Unit::rule(step * 2, 300, 600));
|
||||
if step < 2 {
|
||||
units.push(Unit::vskip(step * 2 + 1, 0));
|
||||
}
|
||||
}
|
||||
let mut document = Document::new(1000, units);
|
||||
document.top_skip = 0;
|
||||
document.output_routine = Some(r"\marks3{carried}\shipout\box255".to_owned());
|
||||
let engine = Engine::layout_paged(&document).expect("paged");
|
||||
assert_eq!(engine.layout.pages.len(), 3);
|
||||
assert_eq!(engine.layout.pages[1].marks[0].class, 3);
|
||||
assert_eq!(engine.layout.pages[1].marks[0].text, "carried");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_routine_can_advance_vsize_for_later_pages() {
|
||||
let mut units = Vec::new();
|
||||
|
||||
@@ -59,8 +59,9 @@ pub struct OutputContext {
|
||||
pub insertion_dimens: [i64; 256],
|
||||
/// TeX `\skip<n>` for insertion class `n`.
|
||||
pub insertion_skips: [i64; 256],
|
||||
/// `\mark{...}` texts written by the routine; they reach later pages.
|
||||
pub output_marks: Vec<String>,
|
||||
/// `\mark{...}`/`\marks<n>{...}` texts written by the routine; they
|
||||
/// reach later pages with their class.
|
||||
pub output_marks: Vec<(u8, String)>,
|
||||
}
|
||||
|
||||
impl Default for OutputContext {
|
||||
@@ -155,7 +156,10 @@ enum Op {
|
||||
Shipout,
|
||||
Relax,
|
||||
Message(String),
|
||||
Mark(String),
|
||||
Mark {
|
||||
class: u8,
|
||||
text: String,
|
||||
},
|
||||
IfDim {
|
||||
left: Dimension,
|
||||
relation: Relation,
|
||||
@@ -520,31 +524,28 @@ fn parse_sequence(tokens: &[Token], index: &mut usize, stop: &[&str]) -> Result<
|
||||
*index += 1;
|
||||
ops.push(Op::Relax);
|
||||
}
|
||||
"message" | "mark" => {
|
||||
let op_name = name.to_owned();
|
||||
"message" => {
|
||||
*index += 1;
|
||||
if !matches!(tokens.get(*index), Some(Token::Open)) {
|
||||
return Err(format!("\\{op_name} expects a braced argument"));
|
||||
}
|
||||
let text = read_braced(tokens, index, "\\message")?;
|
||||
ops.push(Op::Message(text));
|
||||
}
|
||||
"mark" | "marks" => {
|
||||
*index += 1;
|
||||
let mut text = String::new();
|
||||
while *index < tokens.len() {
|
||||
match &tokens[*index] {
|
||||
Token::Close => {
|
||||
*index += 1;
|
||||
break;
|
||||
}
|
||||
token => {
|
||||
text.push_str(&token.to_string());
|
||||
*index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
ops.push(if op_name == "mark" {
|
||||
Op::Mark(text)
|
||||
let class = if name == "mark" {
|
||||
0_u8
|
||||
} else {
|
||||
Op::Message(text)
|
||||
});
|
||||
let class = match tokens.get(*index) {
|
||||
Some(Token::Number { value, unit: None }) => value.round() as i64,
|
||||
_ => return Err("\\marks expects a class number".to_owned()),
|
||||
};
|
||||
*index += 1;
|
||||
if !(0..=255).contains(&class) {
|
||||
return Err("\\marks class must be between 0 and 255".to_owned());
|
||||
}
|
||||
class as u8
|
||||
};
|
||||
let text = read_braced(tokens, index, "\\mark")?;
|
||||
ops.push(Op::Mark { class, text });
|
||||
}
|
||||
"advance" | "multiply" | "divide" => {
|
||||
*index += 1;
|
||||
@@ -876,12 +877,35 @@ fn parse_insertion_class(
|
||||
}
|
||||
}
|
||||
|
||||
fn read_braced(tokens: &[Token], index: &mut usize, name: &str) -> Result<String, String> {
|
||||
if !matches!(tokens.get(*index), Some(Token::Open)) {
|
||||
return Err(format!("{name} expects a braced argument"));
|
||||
}
|
||||
*index += 1;
|
||||
let mut text = String::new();
|
||||
while *index < tokens.len() {
|
||||
match &tokens[*index] {
|
||||
Token::Close => {
|
||||
*index += 1;
|
||||
break;
|
||||
}
|
||||
token => {
|
||||
text.push_str(&token.to_string());
|
||||
*index += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
|
||||
fn execute(ops: &[Op], context: &mut OutputContext, shipped: &mut usize) -> Result<(), String> {
|
||||
for op in ops {
|
||||
match op {
|
||||
Op::Shipout => *shipped += 1,
|
||||
Op::Relax | Op::Message(_) => {}
|
||||
Op::Mark(text) => context.output_marks.push(text.clone()),
|
||||
Op::Mark { class, text } => {
|
||||
context.output_marks.push((*class, text.clone()));
|
||||
}
|
||||
Op::IfDim {
|
||||
left,
|
||||
relation,
|
||||
|
||||
@@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`,
|
||||
`\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and
|
||||
absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the
|
||||
route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and
|
||||
PDF opt-in with `?engine=route-d`). 475 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 476 workspace tests are green and no oracle
|
||||
fixture is ignored.
|
||||
|
||||
Known gaps, in dependency order:
|
||||
@@ -91,7 +91,7 @@ source-level `\hyphenation{...}` exceptions and `\parshape` measures,
|
||||
fragments are rebuilt from the next node index; insertion material is fine
|
||||
because class limits apply at assembly time), though a document that defers
|
||||
bottom floats keeps its initial goal; the paged builder runs the routine
|
||||
page by page, so `\dimen<n>` and `\count<n>` assignments change the insertion limits and reservations of later pages; the configured `\skip<n>` reserves space above its class once per page, and an output-routine `\skip<n>` assignment rebuilds the remaining pages with the new reservation, so later insertion material pays the assigned skip; `\mark{...}` writes inside the routine are carried to the following page's marks; `\box255` content is not inspectable and the full `\output` machinery is still missing;
|
||||
page by page, so `\dimen<n>` and `\count<n>` assignments change the insertion limits and reservations of later pages; the configured `\skip<n>` reserves space above its class once per page, and an output-routine `\skip<n>` assignment rebuilds the remaining pages with the new reservation, so later insertion material pays the assigned skip; `\mark{...}` and classed `\marks<n>{...}` writes inside the routine are carried to the following page's marks; `\box255` content is not inspectable and the full `\output` machinery is still missing;
|
||||
4. `\halign` handles spans/omit/templates but not the full TeX column algorithm;
|
||||
5. math is a compact subset without the CM math fonts (`cmmi`, `cmsy`, `cmex`),
|
||||
display-math line breaking or `\mathchoice`-level styling;
|
||||
|
||||
+3
-3
@@ -129,7 +129,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, `\spaceskip`/`\xspaceskip`, `\raggedright` (infinite `\rightskip`), `\looseness`, `\baselineskip`/`\lineskip`/`\parskip` interline glue, pdfLaTeX oracle matrix 90-240pt plus register, geometry, `\sfcode`, `\parindent`, `\parshape`, `\leftskip`/`\rightskip`, `\hfil`/`\hfill` glue orders, `\prevgraf` in the output routine, and vertical-glue fixtures |
|
||||
| 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` scores candidate breakpoints with TeX page badness, glue setting (with `\raggedbottom`/`\flushbottom` applied when pages are materialised, and TeX glue orders `\vfil`/`\vfill`/`\vfilll` honoured so only the highest order with stretch is used), `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, placing top and bottom floats (with `\floatsep`, a `\bottomfraction` cap and the `\topnumber`/`\bottomnumber`/`\totalnumber` limits, with `\floatpagefraction` deciding when a float-heavy page ships without body) and insertion classes on that path, while in-text floats flow inline as body material; paged layouts replay edits from the edited unit's page and fall back to a full rebuild only when insertions, bottom floats or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset, and `\mark{...}` writes inside the routine are carried to the following page's mark list; `\pageno`, `\outputpenalty` and `\deadcycles` are readable and assignable registers (`\pageno=...` carries into the next page, and an assigned `\vsize` retargets the pages the routine has not seen yet, even when the document raises insertion material; only a document that defers bottom floats keeps its initial goal, because the carried queue cannot be rebuilt after a retarget), `\ht255`, `\dp255` and `\wd255` expose the page box height, depth and width to the routine, and `\hsize` is readable (and assignable for the rest of the run) while `\wd255` tracks it; route-D sets `\hsize` from its 480pt text measure, insertion class registers `\count<n>`/`\dimen<n>`/`\skip<n>` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`) and accept assignments that outlive the routine (the paged builder runs the routine after each page, so an assigned `\dimen<n>` or `\count<n>` changes the insertion capacity and reservation of later pages); the configured `\skip<n>` also reserves space above its class once per page in the paged builder, and a `\skip<n>` assignment rebuilds the pages the routine has not seen yet with the new reservation, `\deadcycles` accumulates pages the output routine did not ship and resets on the next shipout, `\maxdeadcycles` (default 25, assignable) makes the page builder ship the page itself once that many dead cycles have accumulated, `PageFragment::penalty` carries the break penalty (`\outputpenalty`: the penalty value when the break landed on a penalty, otherwise 10000, as TeX reports for glue breaks, goal overflow and the final page), and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine; `\vbadness` reports the badness of the break that produced the page and `\insertpenalties` the number of insertion items held over from it |
|
||||
| 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` scores candidate breakpoints with TeX page badness, glue setting (with `\raggedbottom`/`\flushbottom` applied when pages are materialised, and TeX glue orders `\vfil`/`\vfill`/`\vfilll` honoured so only the highest order with stretch is used), `\topskip`/`\maxdepth`, and `Engine::layout_paged` uses it for documents whose units are single vertical items, placing top and bottom floats (with `\floatsep`, a `\bottomfraction` cap and the `\topnumber`/`\bottomnumber`/`\totalnumber` limits, with `\floatpagefraction` deciding when a float-heavy page ships without body) and insertion classes on that path, while in-text floats flow inline as body material; paged layouts replay edits from the edited unit's page and fall back to a full rebuild only when insertions, bottom floats or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset, and `\mark{...}`/`\marks<n>{...}` writes inside the routine are carried to the following page's mark list with their class; `\pageno`, `\outputpenalty` and `\deadcycles` are readable and assignable registers (`\pageno=...` carries into the next page, and an assigned `\vsize` retargets the pages the routine has not seen yet, even when the document raises insertion material; only a document that defers bottom floats keeps its initial goal, because the carried queue cannot be rebuilt after a retarget), `\ht255`, `\dp255` and `\wd255` expose the page box height, depth and width to the routine, and `\hsize` is readable (and assignable for the rest of the run) while `\wd255` tracks it; route-D sets `\hsize` from its 480pt text measure, insertion class registers `\count<n>`/`\dimen<n>`/`\skip<n>` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`) and accept assignments that outlive the routine (the paged builder runs the routine after each page, so an assigned `\dimen<n>` or `\count<n>` changes the insertion capacity and reservation of later pages); the configured `\skip<n>` also reserves space above its class once per page in the paged builder, and a `\skip<n>` assignment rebuilds the pages the routine has not seen yet with the new reservation, `\deadcycles` accumulates pages the output routine did not ship and resets on the next shipout, `\maxdeadcycles` (default 25, assignable) makes the page builder ship the page itself once that many dead cycles have accumulated, `PageFragment::penalty` carries the break penalty (`\outputpenalty`: the penalty value when the break landed on a penalty, otherwise 10000, as TeX reports for glue breaks, goal overflow and the final page), and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine; `\vbadness` reports the badness of the break that produced the page and `\insertpenalties` the number of insertion items held over from it |
|
||||
| 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 |
|
||||
@@ -359,7 +359,7 @@ M6 (partial): `DisplayItem::Image` becomes a PDF XObject; `DisplayItem::Link` be
|
||||
|
||||
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. A `[t]` float seen while a page is already being filled is installed at the top of that same page, exactly as TeX's `\@toplist` does: the page height gains the float plus one `\textfloatsep` (or `\floatsep` between stacked floats), so the body stops earlier instead of the float waiting for the next page; only a break before the float moves it forward. `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 unit tests covering overfull avoidance, exact glue filling, forced and costed breaks, `\topskip`, `\maxdepth`, marks, insertion limits and top-float placement; every fragment records the penalty that broke it. `Engine::layout_paged` now builds pages through it for documents whose units are single vertical items (boxes, rules, paragraphs, math, haligns, glue, penalties, marks and insertion classes, including per-class limits and held-over material; held-over material starts with `Document::split_top_skip` (TeX `\splittopskip`, default 10pt) when the class capacity can also hold its first item, and `Document::split_max_depth` (TeX `\splitmaxdepth`, `\maxdimen` by default) clamps the first held box's depth while moving the excess into its height); `Document::max_depth` feeds TeX's `\maxdepth` into the builder, and among equal-cost breakpoints the later candidate wins, matching the page builder's `least_page_cost` update with `<=`, so a page can take a later break even when it overfills the goal slightly; when no break fits within the glue shrink, the least overfull break is used instead. Paragraphs also split across pages at line boundaries, so body material no longer overflows a page as one box. Paragraph boxes carry TeX depth: each node reports its last line's descent, so `\pagedepth` sees it, and the builder adds every box descent beyond `\maxdepth` to the page height while keeping the rest as page depth (TeX's per-box rule); route-D sources default `\maxdepth` to LaTeX's 5pt (0.5\topskip), and the page fixtures set it explicitly. A standalone `\smallskip`, `\medskip`, `\bigskip` or `\vskip` line between paragraphs becomes the following unit's `space_before` glue, carrying TeX's width plus its `plus`/`minus` parts (`\smallskip` is 3pt plus 1pt minus 1pt, and so on). Both page builders reserve it, the paged builder gets a real breakpoint with the glue's stretch and shrink, and edits preserve all three components; the command no longer leaks into the paragraph text. `Document::h_offset` and `v_offset` (TeX `\hoffset`/`\voffset`, default zero) feed `pdf::PageOrigin`, and `display_lists_to_pdf_with_paper` translates the page body without moving the sheet; a route-D fixture checks a 10pt/20pt shift against `pdftotext -bbox`, and
|
||||
preview pages apply the same offsets to their display list so the editor and
|
||||
PDF agree. `Document::paper_width` and `paper_height` (TeX `\paperwidth`/`\paperheight`, default US Letter) set the PDF MediaBox and the preview page box, and both route-D endpoints strip leading `\hoffset`/`\voffset`/`\paperwidth`/`\paperheight`/`\vsize`/`\textheight` dimension assignments from the source (preamble included) and apply them, and the same pass reads `\parindent`, `\parskip`, `\baselineskip`, `\leftskip`, `\rightskip`, `\emergencystretch`, `\tolerance`, `\pretolerance`, `\hangindent`/`\hangafter`, `\spaceskip`/`\xspaceskip` and `\frenchspacing` into the paragraph styles; body paragraphs are measured with CMR10/per-face TFM advances rather than fixed cells; `\textheight` wins over `\vsize` because LaTeX resets `\vsize` from `\textheight` on every page, and project previews reuse the same geometry parsing. `Engine::top_mark`, `first_mark` and `bot_mark` implement TeX's carried mark registers per class. `Document::output_routine` runs an interpreted `\output` program over the paged fragments (`output::OutputProgram`: `\shipout\box255`, `\relax`, `\message`, `\ifdim`, `\ifnum`, `\ifodd` and `\ifcase` over the page registers, now including `\pageno`, `\outputpenalty`, `\deadcycles` and `\maxdeadcycles`), dropping pages the routine does not ship. A `\mark{...}` write inside the routine is recorded by the interpreter and placed at the front of the next page's marks, so the carried marks TeX exposes to the following page are reproduced. Assignments such as `\pageno=10`, `\deadcycles=0`, `\count2=2000`, `\dimen2=30pt`, `\skip2=6pt` and `\vsize=300pt` mutate the per-page context; `\advance`, `\multiply` and `\divide` adjust those registers in place (`\advance\pageno by 2`, `\divide\deadcycles by 2`, `\advance\dimen2 by 5pt`), and an arithmetic `\vsize` change retargets later pages exactly like an assignment; `\pageno` and the insertion registers keep their assigned values for later pages, since TeX's output registers are global; Route-D sources map a standalone `\newpage` or `\clearpage` onto `Document::page_breaks`, so the next paragraph starts on a fresh page (the paged builder turns each break into a `-10000` penalty node); the paged builder runs the routine after each page, so an assigned `\vsize` sets the goal of the pages the routine has not seen yet: the remaining fragments are rebuilt from the next node index with the new goal, which works with insertion material because class limits apply while the page is assembled; a deferred bottom float disables the retarget because the carried queue cannot be rebuilt. The `\pagegoal` register handed to the output routine is reduced by the insertion space reserved on that page. `\vbadness` carries the page's break badness and `\insertpenalties` counts insertion items the class limits held over, so an output routine can react to overfull breaks or split insertions. Paged layouts record the node index that starts each page, so `Engine::edit` on a paged layout reuses the sealed prefix and rebuilds only from the edited unit's page onward; an interpreted `\output` routine still forces a full rebuild, and an edit whose replay would begin before the first insertion does too, because held-over material and dropped pages move page boundaries. A document that contains a bottom float likewise rebuilds in full: a deferred float is carried on the page fragment, and a suffix replay starting at a page boundary cannot recover that queue. The scrolling builder's float path remains to be ported. The oracle harness also compares whole pages: ten page fixtures (single-line paragraphs, `\parskip=6pt`, multi-line paragraphs split across pages, a 300pt `\textheight`, a 30pt `\topskip`, a forced `\newpage`, stretchy `\vskip` glue between paragraphs, footnotes raised with `\footnotetext`, and a `[t]` float that reserves its height plus `\textfloatsep` on the page it appears, and `[b]` floats that fit or defer to the next page) assert the same page count and the same per-page alphanumeric text as pdfLaTeX at 345pt measure, 550pt `\vsize`, 12pt `\topskip` and 15pt `\parindent`.
|
||||
PDF agree. `Document::paper_width` and `paper_height` (TeX `\paperwidth`/`\paperheight`, default US Letter) set the PDF MediaBox and the preview page box, and both route-D endpoints strip leading `\hoffset`/`\voffset`/`\paperwidth`/`\paperheight`/`\vsize`/`\textheight` dimension assignments from the source (preamble included) and apply them, and the same pass reads `\parindent`, `\parskip`, `\baselineskip`, `\leftskip`, `\rightskip`, `\emergencystretch`, `\tolerance`, `\pretolerance`, `\hangindent`/`\hangafter`, `\spaceskip`/`\xspaceskip` and `\frenchspacing` into the paragraph styles; body paragraphs are measured with CMR10/per-face TFM advances rather than fixed cells; `\textheight` wins over `\vsize` because LaTeX resets `\vsize` from `\textheight` on every page, and project previews reuse the same geometry parsing. `Engine::top_mark`, `first_mark` and `bot_mark` implement TeX's carried mark registers per class. `Document::output_routine` runs an interpreted `\output` program over the paged fragments (`output::OutputProgram`: `\shipout\box255`, `\relax`, `\message`, `\ifdim`, `\ifnum`, `\ifodd` and `\ifcase` over the page registers, now including `\pageno`, `\outputpenalty`, `\deadcycles` and `\maxdeadcycles`), dropping pages the routine does not ship. A `\mark{...}` or classed `\marks<n>{...}` write inside the routine is recorded by the interpreter and placed at the front of the next page's marks, so the carried marks TeX exposes to the following page are reproduced. Assignments such as `\pageno=10`, `\deadcycles=0`, `\count2=2000`, `\dimen2=30pt`, `\skip2=6pt` and `\vsize=300pt` mutate the per-page context; `\advance`, `\multiply` and `\divide` adjust those registers in place (`\advance\pageno by 2`, `\divide\deadcycles by 2`, `\advance\dimen2 by 5pt`), and an arithmetic `\vsize` change retargets later pages exactly like an assignment; `\pageno` and the insertion registers keep their assigned values for later pages, since TeX's output registers are global; Route-D sources map a standalone `\newpage` or `\clearpage` onto `Document::page_breaks`, so the next paragraph starts on a fresh page (the paged builder turns each break into a `-10000` penalty node); the paged builder runs the routine after each page, so an assigned `\vsize` sets the goal of the pages the routine has not seen yet: the remaining fragments are rebuilt from the next node index with the new goal, which works with insertion material because class limits apply while the page is assembled; a deferred bottom float disables the retarget because the carried queue cannot be rebuilt. The `\pagegoal` register handed to the output routine is reduced by the insertion space reserved on that page. `\vbadness` carries the page's break badness and `\insertpenalties` counts insertion items the class limits held over, so an output routine can react to overfull breaks or split insertions. Paged layouts record the node index that starts each page, so `Engine::edit` on a paged layout reuses the sealed prefix and rebuilds only from the edited unit's page onward; an interpreted `\output` routine still forces a full rebuild, and an edit whose replay would begin before the first insertion does too, because held-over material and dropped pages move page boundaries. A document that contains a bottom float likewise rebuilds in full: a deferred float is carried on the page fragment, and a suffix replay starting at a page boundary cannot recover that queue. The scrolling builder's float path remains to be ported. The oracle harness also compares whole pages: ten page fixtures (single-line paragraphs, `\parskip=6pt`, multi-line paragraphs split across pages, a 300pt `\textheight`, a 30pt `\topskip`, a forced `\newpage`, stretchy `\vskip` glue between paragraphs, footnotes raised with `\footnotetext`, and a `[t]` float that reserves its height plus `\textfloatsep` on the page it appears, and `[b]` floats that fit or defer to the next page) assert the same page count and the same per-page alphanumeric text as pdfLaTeX at 345pt measure, 550pt `\vsize`, 12pt `\topskip` and 15pt `\parindent`.
|
||||
|
||||
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.
|
||||
|
||||
@@ -367,7 +367,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal
|
||||
|
||||
Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`) supplies advances, kerns, ligatures, and italic correction for layout, while the display list and PDF select the matching Liberation face. `Engine::edit` preserves the face when reflowing an edited paragraph.
|
||||
|
||||
The crate currently has 318 unit tests plus seven route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 475 tests (318 route-D unit, 7 route-D integration, 35 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 13 binary units), with none ignored. v1 remains the live server path.
|
||||
The crate currently has 319 unit tests plus seven route-D integration tests and thirty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 476 tests (319 route-D unit, 7 route-D integration, 35 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 13 binary units), with none ignored. v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
|
||||
Reference in new issue
Block a user