Split paragraphs at line boundaries across pages
This commit is contained in:
1 parent
daf9f5c57e
commit
b7b75fbff1
8 files changed
+263
-77
No files matched your search
+14
-13
@@ -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`). 318 workspace tests are green and no oracle
|
||||
PDF opt-in with `?engine=route-d`). 319 workspace tests are green and no oracle
|
||||
fixture is ignored.
|
||||
|
||||
Known gaps, in dependency order:
|
||||
@@ -61,12 +61,13 @@ Known gaps, in dependency order:
|
||||
`\looseness`, and `\baselineskip`/`\lineskip`/`\parskip` interline
|
||||
glue), but not yet custom `\sfcode` overrides, generic `fil`/`fill` glue
|
||||
orders or `\prevgraf`;
|
||||
2. the page builder used by `Document` is still the scrolling builder with
|
||||
fraction policies; `page::PageBuilder` implements the candidate-breakpoint
|
||||
cost model (badness + penalty, glue setting, `\topskip`, `\maxdepth`) and
|
||||
`Engine::layout_paged` runs it for documents made of single-item units, but
|
||||
floats, insertions and incremental checkpoint replay still use the scrolling
|
||||
builder, and an interpreted `\output` is absent;
|
||||
2. the default builder is still the scrolling builder with fraction
|
||||
policies, now with line-level paragraph splits; `page::PageBuilder`
|
||||
implements the candidate-breakpoint cost model (badness + penalty, glue
|
||||
setting, `\topskip`, `\maxdepth`) and `Engine::layout_paged` runs it for
|
||||
documents made of single-item units, but floats, insertions and incremental
|
||||
checkpoint replay still use the scrolling builder, and an interpreted
|
||||
`\output` is absent;
|
||||
3. `\insert` classes model `\count`/`\dimen`/`\skip` but are not TeX
|
||||
registers addressed by number, and there is still no interpreted output
|
||||
routine;
|
||||
@@ -209,14 +210,14 @@ extra line and match pdfLaTeX exactly.
|
||||
Interline spacing follows TeX: the first baseline sits at the paragraph's
|
||||
ascent, each later baseline advances by `\baselineskip` when the resulting gap
|
||||
clears `\lineskiplimit`, otherwise by `\lineskip`, and `\parskip` (default
|
||||
`0pt`) separates paragraph units in the vertical list. Page-level `\topskip`
|
||||
placement remains part of P2, and a paragraph still reserves a whole number of
|
||||
line boxes for pagination.
|
||||
`0pt`) separates paragraph units in the vertical list. A paragraph that does
|
||||
not fit is split at line boundaries: the next fragment continues on the next
|
||||
page without a `\parskip`, and a single unsplittable line may overflow at the
|
||||
top of a page (see `Paragraph::split_at`).
|
||||
|
||||
Still open: generic `fil`/`fill` glue orders, custom `\sfcode` overrides,
|
||||
`\prevgraf`, explicit `\vskip` classes (`\smallskip` and friends), page-level
|
||||
`\topskip` placement, double/final hyphen demerit oracle fixtures, and more
|
||||
width fixtures.
|
||||
`\prevgraf`, explicit `\vskip` classes (`\smallskip` and friends),
|
||||
double/final hyphen demerit oracle fixtures, and more width fixtures.
|
||||
|
||||
### P2 — Vertical list, page builder, `\output` (L2)
|
||||
|
||||
|
||||
+7
-5
@@ -134,9 +134,11 @@ and justification.
|
||||
count (the adjustment is reverted when no feasible layout exists).
|
||||
Interline glue follows TeX: each baseline advances by `\baselineskip` when
|
||||
the resulting gap clears `\lineskiplimit`, otherwise by `\lineskip`;
|
||||
`\parskip` is appended between paragraph units in the vertical list. A
|
||||
paragraph still reserves a whole number of line boxes, so page budgeting is
|
||||
unchanged (page-level `\topskip` placement belongs to M2).
|
||||
`\parskip` is appended between paragraph units in the vertical list. When a
|
||||
paragraph does not fit on the page, the scrolling builder splits it at line
|
||||
boundaries (`Paragraph::split_at`): the fragment keeps its baseline grid on
|
||||
the next page, `\parskip` is not charged inside the paragraph, and only a
|
||||
single unsplittable line is allowed to overflow at the top of a page.
|
||||
Remaining gaps are custom `\sfcode` overrides, generic `fil`/`fill` glue
|
||||
orders outside `\parfillskip`, and `\prevgraf`.
|
||||
|
||||
@@ -304,7 +306,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. `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 seven unit tests. `Engine::layout_paged` now builds pages through it for documents whose units are single vertical items (boxes, rules, paragraphs, math, haligns, glue, penalties and marks); `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. `Document::h_offset` and `v_offset` (TeX `\hoffset`/`\voffset`, default zero) feed `pdf::PageOrigin`, and `display_lists_to_pdf_with_origin` translates the page body without moving the sheet; a route-D fixture checks a 10pt/20pt shift against `pdftotext -bbox`, and the route-D PDF endpoint strips leading `\hoffset`/`\voffset` dimension assignments from the source and applies them. `Engine::top_mark`, `first_mark` and `bot_mark` implement TeX's carried mark registers per class. Floats, insertions and the incremental checkpoint replay still use the scrolling builder, which remains the default until those pieces have a paged equivalent.
|
||||
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. `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 seven unit tests. `Engine::layout_paged` now builds pages through it for documents whose units are single vertical items (boxes, rules, paragraphs, math, haligns, glue, penalties and marks); `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. `Document::h_offset` and `v_offset` (TeX `\hoffset`/`\voffset`, default zero) feed `pdf::PageOrigin`, and `display_lists_to_pdf_with_origin` translates the page body without moving the sheet; a route-D fixture checks a 10pt/20pt shift against `pdftotext -bbox`, and the route-D PDF endpoint strips leading `\hoffset`/`\voffset` dimension assignments from the source and applies them. `Engine::top_mark`, `first_mark` and `bot_mark` implement TeX's carried mark registers per class. Floats, insertions and the incremental checkpoint replay still use the scrolling builder, which remains the default until those pieces have a paged equivalent.
|
||||
|
||||
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.
|
||||
|
||||
@@ -312,7 +314,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 205 unit tests plus seven route-D integration tests and eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 318 tests (205 route-D unit, 7 route-D integration, 8 oracle, 71 v1 integration, 20 server, 4 v1 unit, 1 core unit, 2 binary units), with none ignored. v1 remains the live server path.
|
||||
The crate currently has 206 unit tests plus seven route-D integration tests and eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 319 tests (206 route-D unit, 7 route-D integration, 8 oracle, 71 v1 integration, 20 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