Reuse page prefixes for structural route-D edits

Extract Engine::relayout_from from Engine::edit so a caller can rebuild from any checkpoint with an unchanged unit prefix. Route-D project previews now use the first differing paragraph for both text and structural edits, keeping sealed pages before the change instead of always relaying out the whole document.
This commit is contained in:
gloamxun committed 2026-10-21 08:53:17 +08:00
1 parent 8cbd72663a
commit f2deac541e
4 files changed
+113 -58

No files matched your search

+6 -6
View File
@@ -239,7 +239,7 @@ for a later overlaid slash.
| M4 math | partial | atoms, scripts, fractions, roots, delimiters, accents, operators, classes, braces, boxed, negated; no math painter/shrink wrapping |
| M5 NFSS/TFM | partial | runtime `cmr10.tfm` widths/heights/depths/kern pairs and ff/fi/fl/ffi/ffl ligatures; text faces embed Liberation Serif/Mono as Type0 CID fonts with Identity-H, ToUnicode and width arrays; only faces used on a page are embedded, and ASCII documents use the 110-glyph minimal tier (one-page Roman PDF is about 21 KB); no Base-14 dependency; SVG carries family/weight/style |
| M6 specials/XObject | partial | raw specials, RGB image XObjects, URI link annotations; class/package execution absent |
| M7 incremental integration | partial | route-D preview/PDF/edit endpoints plus opt-in `?engine=route-d` project preview, content-based page hashes and section/emphasis/display-math/itemize/enumerate/description/quote/center/flushright mapping; editor toggle UI and inline math pending |
| M7 incremental integration | partial | route-D preview/PDF/edit endpoints plus opt-in `?engine=route-d` project preview, content-based page hashes and section/emphasis/display-math/itemize/enumerate/description/quote/center/flushright mapping; editor toggle in `texrra-web`; inline math pending |
v1 remains the production renderer; the route-D core is additive and tested independently.
@@ -269,7 +269,7 @@ M3 (partial): `Unit::halign` normalizes column widths, intercolumn gaps, row hei
Math coverage includes fractions/roots, scripts, `\left...\right` with body-scaled delimiters, `\middle`, `\big`/`\Big`/`\bigg`/`\Bigg` and their `l`/`r` forms, control-sequence delimiters, accents (dot/check/breve/acute/grave/ring), `\text`/`\mathrm`, `\overbrace`/`\underbrace`, `\overset`/`\underset`, `\binom`, `\cancel`/`\bcancel`/`\xcancel`, `\bmod`/`\pmod`, fence symbols, `\operatorname*` and `\mathop` limits.
The crate currently has 155 unit tests plus three route-D integration tests. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 254 tests (155 route-D unit, 3 route-D integration, 71 v1 integration, 19 server, 4 v1 unit, 1 core unit, 1 binary unit). v1 remains the live server path.
The crate currently has 156 unit tests plus three route-D integration tests. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 256 tests (156 route-D unit, 3 route-D integration, 71 v1 integration, 19 server, 4 v1 unit, 1 core unit, 2 binary units). v1 remains the live server path.
### M0 incremental demo
@@ -307,10 +307,10 @@ deliberately open rather than approximated:
project preview can opt in with `POST /api/projects/{id}/preview?engine=route-d`;
`route_d::project_preview_json` strips the preamble/body wrapper and keeps a
project-scoped `(paragraphs, Engine)` session. An unchanged source returns
`changedPages: []` and `recomputedPages: 0`; one or more same-count paragraph
edits are applied sequentially through `Engine::edit` from the earliest
changed paragraph and report the changed/recomputed pages, while structural
edits fall back to a full layout. The v1 semantic pipeline remains
`changedPages: []` and `recomputedPages: 0`; same-count paragraph edits and structural edits that keep a
non-empty paragraph prefix are rebuilt from the first difference through
`Engine::relayout_from`, which reuses the sealed pages before that
checkpoint; edits without a reusable prefix fall back to a full layout. The v1 semantic pipeline remains
the default fallback. LaTeX-to-route-D semantic mapping is still a subset, and
`route_d_page_matches_pdftex_raster_geometry` lays out a 480pt CMR10 paragraph at the same scaled-point geometry the server uses, rasterizes the route-D PDF and a pdfTeX Letter page at 72 dpi, and asserts matching ink line count plus left/right/bottom edges. It skips on hosts without `pdflatex`/`pdftoppm`. Exact glyph-outline pixel equality is still open because the two paths use different font outlines.
- `\middle` does not scale with its enclosing delimiter; math delimiters are