From a09b1d1d360e1b14fc0978bfcd3a8709b8675ecc Mon Sep 17 00:00:00 2001 From: GloamXun Date: Fri, 23 Oct 2026 23:35:20 +0800 Subject: [PATCH] Clamp held-over insertion depth with splitmaxdepth --- README.md | 2 +- crates/texrra-tex-core/src/lib.rs | 79 ++++++++++++++++++++++++++++--- docs/ROUTE_D_PLAN.md | 5 +- docs/TEX_CORE.md | 4 +- src/route_d.rs | 6 +++ 5 files changed, 84 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2c35236..cdaa5f3 100644 --- a/README.md +++ b/README.md @@ -590,7 +590,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; with `\raggedright` (`ParagraphStyle::ragged_right`) lines keep their natural widths and fill greedily, because `\rightskip` carries an infinite `fil`. Interline spacing follows TeX (`\baselineskip` unless `\lineskiplimit` forces `\lineskip`), and `Document::par_skip` adds `\parskip` between paragraph units. `page::PageBuilder` selects page breaks by TeX's badness-plus-penalty cost, including glue setting with TeX orders (normal/`\vfil`/`\vfill`/`\vfilll`), `\topskip` and `Document::max_depth` (`\maxdepth`, with each paragraph's last-line descent exposed as `\pagedepth` and only the part beyond `\maxdepth` added to the page height), and breaks ties toward the page closest to the goal; `Engine::layout_paged` exposes it for documents of box/glue/penalty/mark/float/insertion units, expanding each paragraph into one node per line with a zero-width interline breakpoint, and route-D previews and PDFs run through it; insertion classes are placed through the same builder, with per-class limits, held-over material and `Document::split_top_skip` (`\splittopskip`, default 10pt) at the top of each continuation, while `Engine::layout` keeps the scrolling builder as the non-paged fallback; paged layouts replay edits from the edited page, falling back to a full rebuild when insertions or an `\output` routine are present. `Document::output_routine` runs an interpreted `\output` program (`\shipout\box255`, `\relax`, `\message`, `\ifdim`, `\ifnum` and `\ifodd` over page registers; `\pageno`, `\outputpenalty` and `\deadcycles` are readable, and each page fragment records the penalty that broke it and how much stretch each glue order carries, so `\pagefilstretch`, `\pagefillstretch` and `\pagefilllstretch` are readable) over those paged fragments, so a routine can drop pages it does not ship, or ship only the pages it wants based on the break penalty or page number. 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::h_offset` and `v_offset` (`\hoffset`/`\voffset`) shift the exported +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; with `\raggedright` (`ParagraphStyle::ragged_right`) lines keep their natural widths and fill greedily, because `\rightskip` carries an infinite `fil`. Interline spacing follows TeX (`\baselineskip` unless `\lineskiplimit` forces `\lineskip`), and `Document::par_skip` adds `\parskip` between paragraph units. `page::PageBuilder` selects page breaks by TeX's badness-plus-penalty cost, including glue setting with TeX orders (normal/`\vfil`/`\vfill`/`\vfilll`), `\topskip` and `Document::max_depth` (`\maxdepth`, with each paragraph's last-line descent exposed as `\pagedepth` and only the part beyond `\maxdepth` added to the page height), and breaks ties toward the page closest to the goal; `Engine::layout_paged` exposes it for documents of box/glue/penalty/mark/float/insertion units, expanding each paragraph into one node per line with a zero-width interline breakpoint, and route-D previews and PDFs run through it; insertion classes are placed through the same builder, with per-class limits, held-over material and `Document::split_top_skip` (`\splittopskip`, default 10pt) at the top of each continuation, with `Document::split_max_depth` (`\splitmaxdepth`, `\maxdimen` by default) clamping the first continued box's depth and moving the excess into its height, while `Engine::layout` keeps the scrolling builder as the non-paged fallback; paged layouts replay edits from the edited page, falling back to a full rebuild when insertions or an `\output` routine are present. `Document::output_routine` runs an interpreted `\output` program (`\shipout\box255`, `\relax`, `\message`, `\ifdim`, `\ifnum` and `\ifodd` over page registers; `\pageno`, `\outputpenalty` and `\deadcycles` are readable, and each page fragment records the penalty that broke it and how much stretch each glue order carries, so `\pagefilstretch`, `\pagefillstretch` and `\pagefilllstretch` are readable) over those paged fragments, so a routine can drop pages it does not ship, or ship only the pages it wants based on the break penalty or page number. 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::h_offset` and `v_offset` (`\hoffset`/`\voffset`) shift the exported page body through `pdf::PageOrigin`, leaving the sheet size unchanged, while `Document::paper_width`/`paper_height` (`\paperwidth`/`\paperheight`, default US Letter) set the MediaBox and the preview page box; the route-D endpoints read diff --git a/crates/texrra-tex-core/src/lib.rs b/crates/texrra-tex-core/src/lib.rs index 94c221d..28b0e20 100644 --- a/crates/texrra-tex-core/src/lib.rs +++ b/crates/texrra-tex-core/src/lib.rs @@ -655,6 +655,11 @@ pub struct Document { /// carried over to the next page. Defaults to 10pt. #[serde(default = "default_split_top_skip")] pub split_top_skip: i64, + /// TeX's `\splitmaxdepth`: maximum depth kept for the first box of + /// insertion material carried over to the next page. Any excess depth is + /// moved into that box's height. Defaults to `\maxdimen` (no clamping). + #[serde(default = "default_split_max_depth")] + pub split_max_depth: i64, /// TeX floatsep: vertical space between two floats of the same placement /// on one page. Defaults to 12pt. #[serde(default = "default_float_sep")] @@ -708,6 +713,10 @@ fn default_float_sep() -> i64 { 12 * 65_536 } +fn default_split_max_depth() -> i64 { + i64::MAX +} + fn default_split_top_skip() -> i64 { 10 * 65_536 } @@ -769,6 +778,7 @@ impl Document { insertion_classes: Vec::new(), insertion_skip: 0, split_top_skip: default_split_top_skip(), + split_max_depth: default_split_max_depth(), float_sep: default_float_sep(), text_float_sep: default_text_float_sep(), in_text_sep: default_in_text_sep(), @@ -910,13 +920,6 @@ fn document_nodes( } if let VerticalItem::Paragraph(paragraph) = item { if paragraph.lines.len() > 1 { - // Paragraphs built with fixed-cell styles mix raw units with - // TFM extents; only trust a descent that fits the box. - let depth = if paragraph.height > paragraph.depth { - paragraph.depth - } else { - 0 - }; // TeX breaks pages between lines. Expand a paragraph into // one node per line so the page builder is free to break // inside it; each slice renders as its own single-line @@ -1034,6 +1037,42 @@ fn item_height(item: &VerticalItem) -> i64 { } } +/// TeX depth contributed by a vertical item. Only paragraph and math items +/// currently carry depth; boxes have no depth field. +fn item_depth(item: &VerticalItem) -> i64 { + match item { + VerticalItem::Paragraph(paragraph) => paragraph.depth, + VerticalItem::Math { depth, .. } => *depth, + _ => 0, + } +} + +/// TeX `\splitmaxdepth`: clamp the depth of the first box in held-over +/// insertion material, moving the excess depth into its height so the page +/// accounts for it exactly once. +fn clamp_split_depth(document: &Document, material: &mut [VerticalItem]) { + let limit = document.split_max_depth.max(0); + for item in material.iter_mut() { + let depth = item_depth(item); + if depth <= limit { + continue; + } + let excess = depth - limit; + match item { + VerticalItem::Paragraph(paragraph) => { + paragraph.height += excess; + paragraph.depth = limit; + } + VerticalItem::Math { height, depth, .. } => { + *height += excess; + *depth = limit; + } + _ => {} + } + return; + } +} + /// TeX `\prevgraf` for a finished page: the line count of the last paragraph /// broken on it. fn page_prev_graf(page: &Page) -> i64 { @@ -1070,6 +1109,7 @@ fn held_insertion_material( if !material.is_empty() && split > 0 && capacity >= split.saturating_add(first) { material.insert(0, VerticalItem::Glue(split)); } + clamp_split_depth(document, &mut material); material } @@ -3901,6 +3941,31 @@ mod tests { assert_eq!(second.height, 80 * scale); } + #[test] + fn split_max_depth_clamps_the_first_held_item() { + let scale = 65_536; + let mut document = Document::new(1000 * scale, vec![]); + document.split_top_skip = 0; + document.split_max_depth = 3 * scale; + let material = held_insertion_material( + &document, + 1000 * scale, + vec![VerticalItem::Math { + atom: crate::math::MathAtom::Symbol('x'), + width: scale, + height: 20 * scale, + depth: 10 * scale, + }], + ); + match &material[0] { + VerticalItem::Math { height, depth, .. } => { + assert_eq!(*depth, 3 * scale); + assert_eq!(*height, 27 * scale); + } + other => panic!("unexpected material {other:?}"), + } + } + #[test] fn insertion_skip_reserves_space_before_the_first_insertion() { let insertion = || { diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 7284ffa..ee6bd6a 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`). 457 workspace tests are green and no oracle +PDF opt-in with `?engine=route-d`). 458 workspace tests are green and no oracle fixture is ignored. Known gaps, in dependency order: @@ -266,7 +266,8 @@ Scope: TeX register semantics, `\marks` remains open); - insertions: `\insert` with `\count`, `\dimen`, `\skip` per class, split insertions, held-over material with `\splittopskip` leading each - continuation, `\footins` defaults (the three registers are + continuation and `\splitmaxdepth` clamping the first continued box's + depth (excess moves into its height), `\footins` defaults (the three registers are now modelled by `InsertionClass::multiplier`, `max_height` and `skip`, and the fitting head stays on the anchor page with the tail held over; TeX's register arithmetic remains); diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index b657fde..f0ff60c 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -351,7 +351,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. 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); `Document::max_depth` feeds TeX's `\maxdepth` into the builder, and among equal-cost breakpoints the candidate closest to the page goal wins, so an overfull page takes the least overfull break. 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 +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 candidate closest to the page goal wins, so an overfull page takes the least overfull break. 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. 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); for documents without insertions or floats 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 `\pagegoal` register handed to the output routine is reduced by the insertion space reserved on that page. 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. The scrolling builder's float path remains to be ported. The oracle harness also compares whole pages: nine 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) assert the same page count and the same per-page alphanumeric text as pdfLaTeX at 345pt measure, 550pt `\vsize`, 12pt `\topskip` and 15pt `\parindent`. @@ -361,7 +361,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 303 unit tests plus seven route-D integration tests and thirty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 457 tests (303 route-D unit, 7 route-D integration, 32 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 304 unit tests plus seven route-D integration tests and thirty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 458 tests (304 route-D unit, 7 route-D integration, 32 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 diff --git a/src/route_d.rs b/src/route_d.rs index b5960b8..581a13b 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -131,6 +131,7 @@ struct PageGeometry { top_skip: Option, max_depth: Option, split_top_skip: Option, + split_max_depth: Option, hyphen_penalty: Option, ex_hyphen_penalty: Option, double_hyphen_demerits: Option, @@ -213,6 +214,8 @@ fn strip_page_geometry(source: &str) -> (String, PageGeometry) { 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) = dimension_assignment(trimmed, "splitmaxdepth") { + geometry.split_max_depth = Some(value); } else if let Some(value) = parfillskip_assignment(trimmed) { geometry.par_fillskip = Some(value); } else if let Some(value) = parshape_assignment(trimmed) { @@ -273,6 +276,9 @@ fn apply_geometry(document: &mut Document, geometry: &PageGeometry) { if let Some(skip) = geometry.split_top_skip { document.split_top_skip = skip; } + if let Some(depth) = geometry.split_max_depth { + document.split_max_depth = depth; + } } /// Read a `\parfillskip` glue assignment, preserving the `1fil` order.