diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index e759a28..061909b 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -49,7 +49,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`, 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`; flat `/preview` and project previews now -prefer route-D with a v1 fallback). 1001 workspace tests are green and no oracle +prefer route-D with a v1 fallback). 1002 workspace tests are green and no oracle fixture is ignored. Preview JSON also carries a `warnings` array naming environments route-D cannot lay out and control words that survived layout, so unsupported source is reported instead of being silently typeset. diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index afdc6c7..e458588 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -370,7 +370,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`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph. -The crate currently has 437 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1001 tests (437 route-D unit, 374 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 62 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; the flat response carries `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4. +The crate currently has 437 unit tests plus ten route-D integration tests and forty-two oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 1002 tests (437 route-D unit, 375 engine binary unit, 10 route-D integration, 42 oracle, 71 v1 integration, 62 server, 4 engine unit, 1 core unit), with none ignored. The flat `/preview` endpoint and the project preview/PDF endpoints now try route-D first and fall back to v1 on error (`?engine=v1` or `TEXRRA_ENGINE=v1` forces v1; the flat response carries `X-Preview-Engine`, naming the engine used). A geometry-less project now defaults to Letter, matching pdfLaTeX, where the old v1 path used A4. ### M0 incremental demo @@ -544,10 +544,11 @@ are: the body expand their bodies (including `\csname`) when read, while a plain `\def` stays lazy. A runtime `\def` also parses its parameter text, so a body-embedded `\def\foo#1{...}` (undelimited or delimited) expands with its - arguments instead of leaking. A `\catcode` assignment is recognised for `@` - (backtick, bare or code-point target, values 11/12), so class files that set - the catcode directly instead of using `\makeatletter` work; catcodes for any - other character are still unmodelled, and there is no token stream. A runtime + arguments instead of leaking. A `\catcode` assignment is consumed for any + target (backtick, bare or code-point form); only `@` (values 11/12) changes + scanning, so class files that set it directly instead of using + `\makeatletter` work, while other catcode values are recorded but not applied + yet. There is no token stream. A runtime `\csname ... \endcsname` (also inside ordinary macro bodies) expands its contents and resolves the named macro, yielding nothing when undefined. `\futurelet\alias\command ` binds the looked-ahead token to the diff --git a/src/route_d.rs b/src/route_d.rs index b757071..a3b649e 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -5750,11 +5750,13 @@ fn canonicalize_at_catcodes(source: &str) -> String { } "catcode" => { if let Some((target, value, next)) = catcode_assignment(&characters, end) { + // Only the @ catcode changes scanning; the other + // assignments are consumed so they do not leak as text. if target == '@' { at_letter = value == 11; - index = next; - continue; } + index = next; + continue; } } _ => {} @@ -15767,6 +15769,29 @@ A definition. assert!(!text.contains("makeatletter"), "{text}"); } + #[test] + fn other_catcode_assignments_are_consumed() { + let source = "\\documentclass{article}\n\\begin{document}\n\n\\catcode`\\#=12\n\\catcode`\\_=12\n\n#hash and a_b.\n\n\\end{document}\n"; + let json = preview_json(source).expect("preview"); + let value: serde_json::Value = serde_json::from_str(&json).expect("JSON"); + assert_eq!( + value["warnings"].as_array().map(Vec::len), + Some(0), + "{}", + value["warnings"] + ); + let svg = value["pages"][0]["svg"].as_str().expect("svg"); + let text: String = svg + .split('>') + .filter_map(|piece| piece.split('<').next()) + .collect::() + .split_whitespace() + .collect(); + assert!(text.contains("#hash"), "{text}"); + assert!(text.contains("a_b."), "{text}"); + assert!(!text.contains("catcode"), "{text}"); + } + #[test] fn afterassignment_runs_after_the_assignment() { let source = "\\documentclass{article}\n\\begin{document}\n\n\\newcount\\a\n\\def\\hello{H}\n\\afterassignment\\hello\\a=5\n\nText.\n\n\\end{document}\n";