diff --git a/crates/texrra-tex-core/src/lib.rs b/crates/texrra-tex-core/src/lib.rs index ad26e6a..b5a6ddb 100644 --- a/crates/texrra-tex-core/src/lib.rs +++ b/crates/texrra-tex-core/src/lib.rs @@ -578,7 +578,6 @@ impl Page { self.insertions.hash(&mut hasher); self.marks.hash(&mut hasher); self.floats.hash(&mut hasher); - self.sources.hash(&mut hasher); self.hash = hasher.finish(); } } @@ -1171,6 +1170,9 @@ impl Engine { { pages.push(current); } + for page in &mut pages { + page.sources.clear(); + } for (index, unit) in next.units.iter().enumerate() { if let Some(checkpoint) = checkpoints.get(index) && let Some(page) = pages.get_mut(checkpoint.page_index) @@ -1346,6 +1348,22 @@ mod tests { assert_eq!(with_top_skip.layout.pages.len(), 2); } + #[test] + fn editing_keeps_earlier_page_sources_stable() { + let mut document = Document::new( + 100, + vec![ + Unit::paragraph(1, "a ".repeat(200)), + Unit::paragraph(2, "b ".repeat(200)), + ], + ); + let mut engine = Engine::layout(&document); + let before = engine.pages()[0].hash; + engine.edit(&document, 2, "c ".repeat(200)); + assert_eq!(engine.pages()[0].hash, before); + document.units[1].source = "c ".repeat(200); + } + #[test] fn vertical_penalty_can_force_a_page_break() { let unit = Unit { diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index 0cb696f..af75a39 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -232,7 +232,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; all five text faces embed Liberation Serif/Mono as Type0 CID fonts with Identity-H, ToUnicode and `/W` glyph widths; 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 with page hashes and basic section/emphasis mapping; editor integration pending | +| M7 incremental integration | partial | route-D preview/PDF/edit endpoints with content-based page hashes and basic section/emphasis mapping; editor integration pending | v1 remains the production renderer; the route-D core is additive and tested independently. @@ -262,7 +262,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 137 unit tests plus one route-D integration test. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 222 tests (137 route-D unit, 1 route-D integration, 71 v1 integration, 8 server, 4 v1 unit, 1 doctest). v1 remains the live server path. +The crate currently has 138 unit tests plus one route-D integration test. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 223 tests (138 route-D unit, 1 route-D integration, 71 v1 integration, 8 server, 4 v1 unit, 1 doctest). v1 remains the live server path. ### M0 incremental demo @@ -292,6 +292,9 @@ deliberately open rather than approximated: - **M5**: `cmr10.tfm` is parsed at runtime with widths, glyph heights/depths and kern pairs. all five text faces embed Liberation Serif/Mono as Type0/Identity-H with `/W` widths; ff/fi/fl/ffi/ffl ligatures come from TFM, and CMR10 italic corrections are applied at line ends; full NFSS family switching is not implemented. - **M6**: `\output`, `\insert`, mark/float output policies, class-file execution and math limit policies are only partially modeled; `OutputRoutine::wants_break` can force a page break between units, and insertion material is stacked by class from the page bottom; `\output` is still Rust code rather than interpreted tokens. +- Page hashes cover rendered items/insertions/marks/floats, not source-dependency + metadata, so replaying an earlier page cannot change its hash merely by + re-attaching source hashes. - **M7**: `POST /api/route-d/preview`, `/api/route-d/pdf` and `/api/route-d/edit/{unit}` expose route-D pages, PDF export and edit diff; the preview path lays out blank-line-separated plain text and returns route-D pages with SVG and page