Files
texrra-engine/docs/ROUTE_D_STATUS.md
T
gloamxun 8a5411af1d Expand counter formatting commands
\arabic, \roman, \Roman, \alph, \Alph and \value with a counter name were
unsupported and leaked into the text. The body pass now reads the braced counter
name and replaces the command with its stored value in the requested form,
using the same counter table that \setcounter/\stepcounter fill.

A preview test sets section to 4 and checks "4 iv D 4." with no warnings.
2026-10-27 03:24:00 +08:00

4.5 KiB
Executable File

Route-D status (handoff after the round-150 recovery)

Status: active on main in texrra-engine (the tree is clean after each push). This page collects what route-D currently does, how to verify it, and the limits that remain. It is the short companion to the long implementation log in ROUTE_D_PLAN.md and the model notes in TEX_CORE.md.

Verification

Run from the repository root:

cargo fmt --all -- --check
cargo test --workspace --offline

The workspace currently passes 1046 tests:

Suite Tests
route-D unit (engine) 439
engine binary unit 416
server integration 63
v1 integration 71
pdfLaTeX oracle 42
route-D integration 10
engine/core unit 4 + 1

The oracle suite compiles fixtures with pdflatex, extracts word boxes with pdftotext -bbox/pdftoppm, and compares route-D page geometry; it skips (saying so) when the TeX tools are absent. The server suite includes corpus_documents_preview_without_warnings, which previews examples/hello.tex, examples/boxes.tex, examples/compat.tex and fixtures/arxiv-template/template.tex and asserts 200, the expected page count (1/1/1/2) and an empty warnings array for each. A manual sweep of the same four documents reports 0 warnings and under 1.5 s per preview.

Service defaults

  • Flat POST /preview and the project preview/PDF endpoints try route-D first and fall back to v1 on error. The flat response carries X-Preview-Engine: route-d|v1.
  • ?engine=v1 or TEXRRA_ENGINE=v1 forces the old pipeline; an explicit ?engine= wins over the environment.
  • /api/route-d/preview, /api/route-d/pdf and /api/route-d/edit/{unit} remain the explicit route-D surface.
  • Geometry-less documents default to Letter (pdfLaTeX's default), not the old v1 A4 default.

Implemented areas

  • Paragraphs/pages: Knuth-Plass breaking with prefix-sum candidates, hyphenation, justification, \parindent/\parskip, baselineskip/\lineskip, TeX badness page breaking with glue orders, \topskip/\maxdepth, insertion classes, marks, floats, \output program, incremental page replay.
  • Macros: textual expansion with group scopes ({}, \begingroup), \def/\gdef/\edef/\xdef, delimited and undelimited parameters, \let, \chardef, \newif, \csname, \expandafter, \futurelet, \aftergroup, \afterassignment, \scantokens, token registers, \string, \meaning, \expanded, \unexpanded, \detokenize; @ and % catcodes are applied.
  • Boxes: \sbox/\savebox measured at definition (width/height/depth, image bodies use decoded pixels), frozen dimensions, \wd/\ht/\dp, unbreakable \mbox/\usebox, \parbox content, framed/colour boxes.
  • Tables: tabular/longtable, \multicolumn, \multirow, p{} wrapping, \tabskip/\tabcolsep, booktabs rules, row splitting, real nested tabulars, and \valign transposed into a tabular.
  • Math: CM metrics and Type1 faces, fractions/scripts/delimiters, aligned environments, operators, and inline math scaled proportionally at any paragraph size.
  • Fonts: twelve CM text faces and four math faces, Liberation fallback per glyph, Greek/Cyrillic/accents, Greek math commands, fontspec family aliases.
  • Service: both preview paths default to route-D with v1 fallback, caches and sessions, engine-labelled flat responses.

Known limits

  • Expansion is textual, not a token stream; the catcode table models only @ and % (other \catcode assignments are consumed but not applied).
  • Complex-script shaping (Devanagari, Thai, emoji) has no fallback face; this is outside pdfLaTeX's own scope and is reported rather than silently mis-set.
  • A \parbox keeps its content unbreakable; its width argument does not wrap.
  • Images inside a nested table are not merged into the outer display list.
  • \valign cells are left-aligned; its preamble alignments/vertical rules are ignored.
  • \unexpanded freezes its tokens during an edef-style pass and they expand at use time; the wider token-stream semantics of \edef remain textual.

Continuing

  1. Read TEX_CORE.md for the model and ROUTE_D_PLAN.md for the phase history.
  2. Pick a limit above, add a route-D unit test (and a server/corpus test when user-visible), update the relevant doc paragraph, and push to main.
  3. Keep cargo fmt --all -- --check and the full workspace suite green before every push; the oracle suite needs pdflatex, pdftotext and pdftoppm.