Read page skip registers from route-D sources
This commit is contained in:
1 parent
bd462448d5
commit
e823a1f415
3 files changed
+40
-5
No files matched your search
@@ -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`). 431 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 432 workspace tests are green and no oracle
|
||||
fixture is ignored.
|
||||
|
||||
Known gaps, in dependency order:
|
||||
@@ -56,7 +56,8 @@ Known gaps, in dependency order:
|
||||
1. paragraph breaking reproduces TeX's passes and demerits (including
|
||||
`\adjdemerits`, `\doublehyphendemerits`, `\finalhyphendemerits`,
|
||||
source-level `\hyphenation{...}` exceptions and `\parshape` measures,
|
||||
`\parfillskip`, `\lineskip` and `\lineskiplimit`,
|
||||
`\parfillskip`, `\lineskip`, `\lineskiplimit`, `\topskip`, `\maxdepth`
|
||||
and `\splittopskip`,
|
||||
`\hyphenpenalty`, `\exhyphenpenalty`, `\hyphenation` exceptions,
|
||||
`\hangindent`/`\hangafter`/`\parshape` line geometry, `\parfillskip`
|
||||
with or without `fil`, default `\sfcode` sentence spacing,
|
||||
|
||||
+4
-3
@@ -73,8 +73,9 @@ stretches normal glue past its nominal stretch (badness simply exceeds 100)
|
||||
and clamps shrink at the declared limit, so overfull lines stay overfull
|
||||
exactly as in TeX. Each line can take its measure and left offset from
|
||||
`\hangindent`/`\hangafter` or an explicit `\parshape` list (the route-D
|
||||
service reads `\parshape=...`, `\parfillskip`, `\lineskip` and
|
||||
`\lineskiplimit` lines from the source); the display list
|
||||
service reads `\parshape=...`, `\parfillskip`, `\lineskip`,
|
||||
`\lineskiplimit`, `\topskip`, `\maxdepth` and `\splittopskip` lines from the
|
||||
source); the display list
|
||||
honours the same offsets. The bounds and hyphen demerits are `ParagraphStyle`
|
||||
fields mirroring `\pretolerance`, `\tolerance`, `\hyphenpenalty` and
|
||||
`\exhyphenpenalty`, `\linepenalty`, `\adjdemerits`,
|
||||
@@ -349,7 +350,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 289 unit tests plus seven route-D integration tests and twenty-seven oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 431 tests (289 route-D unit, 7 route-D integration, 27 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 6 binary units), with none ignored. v1 remains the live server path.
|
||||
The crate currently has 289 unit tests plus seven route-D integration tests and twenty-seven oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 432 tests (289 route-D unit, 7 route-D integration, 27 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 7 binary units), with none ignored. v1 remains the live server path.
|
||||
|
||||
### M0 incremental demo
|
||||
|
||||
|
||||
@@ -126,6 +126,9 @@ struct PageGeometry {
|
||||
lineskip: Option<i64>,
|
||||
lineskiplimit: Option<i64>,
|
||||
par_fillskip: Option<(i64, i64, bool)>,
|
||||
top_skip: Option<i64>,
|
||||
max_depth: Option<i64>,
|
||||
split_top_skip: Option<i64>,
|
||||
}
|
||||
|
||||
/// Pull `\hoffset`/`\voffset`/`\paperwidth`/`\paperheight`/`\vsize`/
|
||||
@@ -179,6 +182,12 @@ fn strip_page_geometry(source: &str) -> (String, PageGeometry) {
|
||||
geometry.lineskip = Some(value);
|
||||
} else if let Some(value) = dimension_assignment(trimmed, "lineskiplimit") {
|
||||
geometry.lineskiplimit = Some(value);
|
||||
} else if let Some(value) = dimension_assignment(trimmed, "topskip") {
|
||||
geometry.top_skip = Some(value);
|
||||
} else if let Some(value) = dimension_assignment(trimmed, "maxdepth") {
|
||||
geometry.max_depth = Some(value);
|
||||
} else if let Some(value) = dimension_assignment(trimmed, "splittopskip") {
|
||||
geometry.split_top_skip = Some(value);
|
||||
} else if let Some(value) = parfillskip_assignment(trimmed) {
|
||||
geometry.par_fillskip = Some(value);
|
||||
} else if let Some(value) = parshape_assignment(trimmed) {
|
||||
@@ -224,6 +233,15 @@ fn apply_geometry(document: &mut Document, geometry: &PageGeometry) {
|
||||
if let Some(skip) = geometry.par_skip {
|
||||
document.par_skip = skip;
|
||||
}
|
||||
if let Some(skip) = geometry.top_skip {
|
||||
document.top_skip = skip;
|
||||
}
|
||||
if let Some(depth) = geometry.max_depth {
|
||||
document.max_depth = depth;
|
||||
}
|
||||
if let Some(skip) = geometry.split_top_skip {
|
||||
document.split_top_skip = skip;
|
||||
}
|
||||
}
|
||||
|
||||
/// Read a `\parfillskip` glue assignment, preserving the `1fil` order.
|
||||
@@ -898,4 +916,19 @@ mod source_tests {
|
||||
assert_eq!(style.lineskip, 2 * SCALE);
|
||||
assert_eq!(style.lineskiplimit, 3 * SCALE);
|
||||
}
|
||||
#[test]
|
||||
fn geometry_reads_page_skip_registers() {
|
||||
let source = "\\documentclass{article}\n\\topskip=10pt\n\\maxdepth=5pt\n\\splittopskip=3pt\n\\begin{document}\n\nSome words here.\n\n\\end{document}\n";
|
||||
let (body, geometry) = geometry_and_body(source);
|
||||
assert_eq!(geometry.top_skip, Some(10 * SCALE));
|
||||
assert_eq!(geometry.max_depth, Some(5 * SCALE));
|
||||
assert_eq!(geometry.split_top_skip, Some(3 * SCALE));
|
||||
assert!(!body.contains("topskip"));
|
||||
let paragraphs = paragraphs(&body).expect("paragraphs");
|
||||
let mut document = build_document(¶graphs, &geometry);
|
||||
apply_geometry(&mut document, &geometry);
|
||||
assert_eq!(document.top_skip, 10 * SCALE);
|
||||
assert_eq!(document.max_depth, 5 * SCALE);
|
||||
assert_eq!(document.split_top_skip, 3 * SCALE);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user