diff --git a/crates/texrra-tex-core/tests/oracle.rs b/crates/texrra-tex-core/tests/oracle.rs index adaa1ae..7bb4795 100644 --- a/crates/texrra-tex-core/tests/oracle.rs +++ b/crates/texrra-tex-core/tests/oracle.rs @@ -568,6 +568,52 @@ fn looseness_matches_pdftex() { } } +/// Hyphenation inserts discretionary breaks; line endings and the resulting +/// fragment words must match pdfLaTeX. +#[test] +fn hyphenated_breaks_match_pdftex() { + let text = "hyphenation demonstrates discretionary hyphenation whenever extraordinarily \ + unpronounceable words appear in a paragraph"; + for width in [80_u32, 100, 120] { + let Some(reference) = pdftex_lines(¶graph_fixture_with(text, width, "")) else { + eprintln!("skipping: pdflatex/pdftotext are not installed"); + return; + }; + let ours = route_d_lines_with(text, f64::from(width), |_| {}); + assert_lines_match(&format!("hyphenation {width}pt"), &ours, &reference); + } +} + +/// `\\doublehyphendemerits` and `\\finalhyphendemerits` change which +/// breaks pdfLaTeX picks; both settings must reproduce its lines. +#[test] +fn hyphen_demerits_change_breaks_like_pdftex() { + let text = "hyphenation demonstrates discretionary representation according \ + extraordinary understanding"; + for width in [70_u32, 85] { + for demerits in [0_i64, 10_000] { + let prefix = format!( + "\\doublehyphendemerits={demerits} \\finalhyphendemerits={} ", + demerits / 2 + ); + let Some(reference) = pdftex_lines(¶graph_fixture_with(text, width, &prefix)) + else { + eprintln!("skipping: pdflatex/pdftotext are not installed"); + return; + }; + let ours = route_d_lines_with(text, f64::from(width), |style| { + style.double_hyphen_demerits = demerits; + style.final_hyphen_demerits = demerits / 2; + }); + assert_lines_match( + &format!("hyphen demerits {demerits} at {width}pt"), + &ours, + &reference, + ); + } + } +} + /// Sentence punctuation changes the space factor, so the interword glue and /// the resulting line breaks must match pdfLaTeX. #[test] diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 8e78800..1fc789d 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -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`). 426 workspace tests are green and no oracle +PDF opt-in with `?engine=route-d`). 428 workspace tests are green and no oracle fixture is ignored. Known gaps, in dependency order: @@ -233,12 +233,13 @@ page without a `\parskip`, and a single unsplittable line may overflow at the top of a page (see `Paragraph::split_at`). Still open: explicit -`\vskip` classes (`\smallskip` and friends), -double/final hyphen demerit oracle fixtures. The breaker now rejects overfull +`\vskip` classes (`\smallskip` and friends). The breaker now rejects overfull lines outside the emergency pass, exactly like TeX, so `\tolerance` cannot -smuggle in a single overfull line any more; at `\tolerance=10000` the line -count matches pdfLaTeX but the first line boundary still differs, so the -demerit fixtures stay open until that trade-off is understood. +smuggle in a single overfull line any more. Hyphenated breaks are checked at +80-120pt, and a 70/85pt fixture sets `\doublehyphendemerits` and +`\finalhyphendemerits` to 0 and 10000 so both demerits change the reference +breaks; at `\tolerance=10000` the line count matches pdfLaTeX but the first +line boundary still differs, which stays documented as a known approximation. ### P2 — Vertical list, page builder, `\output` (L2) diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index d24f017..7179e7e 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -86,7 +86,9 @@ horizontally. The narrowest measures exercise hyphenated and overfull breaks (in final line held at its declared shrink limit), 130-160pt the final-pass overfull box, and 180-240pt ordinary tolerance solutions. Two further fixtures pin register behaviour at 120pt: `\pretolerance=10000` stops before hyphenation and `\hyphenpenalty=10000` -inhibits it, leaving the overfull first-fit lines TeX produces. A 120pt +inhibits it, leaving the overfull first-fit lines TeX produces. Hyphenated paragraphs are compared at 80, 100 and 120pt, and a +70/85pt fixture runs with `\doublehyphendemerits` and `\finalhyphendemerits` +at 0 and 10000 so the reference breaks change with the demerits. A 120pt fixture with `\hangindent=20pt \hangafter=1` checks every line origin against pdfLaTeX as well as the word positions inside each line, and a `\parfillskip=0pt` fixture checks that a final line without `fil` glue is @@ -344,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 289 unit tests plus seven route-D integration tests and twenty-five oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 426 tests (289 route-D unit, 7 route-D integration, 25 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 3 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 428 tests (289 route-D unit, 7 route-D integration, 27 oracle, 71 v1 integration, 26 server, 4 v1 unit, 1 core unit, 3 binary units), with none ignored. v1 remains the live server path. ### M0 incremental demo