Count dead cycles across output routine pages
This commit is contained in:
1 parent
66dfb10b60
commit
2a3393a61e
3 files changed
+32
-4
No files matched your search
@@ -1871,6 +1871,7 @@ impl Engine {
|
||||
if let Some(source) = &document.output_routine {
|
||||
let program = output::OutputProgram::parse(source).ok()?;
|
||||
let mut shipped = Vec::new();
|
||||
let mut deadcycles = 0_i64;
|
||||
for (index, page) in pages.into_iter().enumerate() {
|
||||
let page_total: i64 = page.items.iter().map(item_height).sum();
|
||||
let mut insertion_counts = [1000_i64; 256];
|
||||
@@ -1899,10 +1900,15 @@ impl Engine {
|
||||
insertion_dimens,
|
||||
insertion_skips,
|
||||
pageno: index as i64 + 1,
|
||||
deadcycles: 0,
|
||||
deadcycles,
|
||||
};
|
||||
if program.shipout_count(&context).ok()? > 0 {
|
||||
shipped.push(page);
|
||||
deadcycles = 0;
|
||||
} else {
|
||||
// TeX counts a page the output routine does not ship as a
|
||||
// dead cycle; the count resets on the next shipout.
|
||||
deadcycles += 1;
|
||||
}
|
||||
}
|
||||
pages = shipped;
|
||||
@@ -5405,6 +5411,28 @@ mod tests {
|
||||
assert_eq!(engine.pages().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dead_cycles_accumulate_until_the_next_shipout() {
|
||||
let mut document = Document::new(100, Vec::new());
|
||||
document.output_routine = Some(r"\ifnum\deadcycles=1\shipout\box255\fi".to_owned());
|
||||
document.units = vec![
|
||||
Unit::rule(0, 10, 40),
|
||||
Unit::penalty(1, -10_000),
|
||||
Unit::rule(2, 10, 50),
|
||||
Unit::penalty(3, -10_000),
|
||||
Unit::rule(4, 10, 60),
|
||||
];
|
||||
let engine = Engine::layout_paged(&document).expect("paged layout");
|
||||
assert_eq!(engine.pages().len(), 1);
|
||||
assert_eq!(
|
||||
engine.pages()[0].items[0],
|
||||
VerticalItem::Rule {
|
||||
width: 10,
|
||||
height: 50
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_routine_reads_insertion_registers() {
|
||||
let mut document = Document::new(100, vec![Unit::rule(0, 10, 40)]);
|
||||
|
||||
@@ -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`). 401 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 402 workspace tests are green and no oracle
|
||||
fixture is ignored.
|
||||
|
||||
Known gaps, in dependency order:
|
||||
|
||||
+2
-2
@@ -116,7 +116,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` and vertical-glue fixtures; 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; `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 or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset; `\pageno`, `\outputpenalty` and `\deadcycles` are readable registers, insertion class registers `\count<n>`/`\dimen<n>`/`\skip<n>` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`), `PageFragment::penalty` carries the break penalty, and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine |
|
||||
| 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 or an interpreted `\output` are present; `\output` is interpreted for a `\shipout`/`\ifdim`/`\ifnum`/`\ifodd`/`\ifcase` subset; `\pageno`, `\outputpenalty` and `\deadcycles` are readable registers, insertion class registers `\count<n>`/`\dimen<n>`/`\skip<n>` read the configured multiplier, maximum height and skip of class `n` (with `\count0` reading `\pageno`), `\deadcycles` accumulates pages the output routine did not ship and resets on the next shipout, `PageFragment::penalty` carries the break penalty, and `PageFragment::stretches` records glue stretch per TeX order so `\pagefilstretch`/`\pagefillstretch`/`\pagefilllstretch` are readable in the output routine |
|
||||
| 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 |
|
||||
@@ -346,7 +346,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 277 unit tests plus seven route-D integration tests and seventeen oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 401 tests (277 route-D unit, 7 route-D integration, 17 oracle, 71 v1 integration, 22 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
|
||||
The crate currently has 278 unit tests plus seven route-D integration tests and seventeen oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 402 tests (278 route-D unit, 7 route-D integration, 17 oracle, 71 v1 integration, 22 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
|
||||
Reference in new issue
Block a user