Commit Graph
714 Commits
Author SHA1 Message Date
gloamxun b1e3e03f00 Fix the arXiv-template PDF output
The user-supplied template PDF exposed four concrete problems:

- title/headings were letter-spaced: plain text in a large paragraph took the
  SizedText segment path and was scaled twice; the fallback run now stays at
  the base size and is scaled once by the paragraph;
- the table lost its third column because unsupported math glyphs were sent
  through the PDF fallback font; table-cell math now has a readable ASCII
  fallback (Size (um), approx. 100, 10**6);
- fancyhdr's \cfoot{\thepage} was painted together with route-D's default page
  number; default numbering is skipped for a fancy pagestyle;
- .bib data was ignored; simple @article/@inproceedings entries are now parsed
  from project .bib files, inlined as thebibliography entries, and resolved by
  the existing citation pass, producing References and [1]-[3].

The regenerated 3-page PDF was checked for title/heading spacing, table text,
references and a single page number per page. A project regression test covers
the .bib path, and the table/heading fixes have unit tests.

Remaining visible limits in this template: the complex display equation, the
\fbox/rule figure body, vector/PDF images and the author block layout.
Test count moves to 1069 (444 core, 432 engine, 65 server).
2026-10-27 13:38:36 +08:00
gloamxun fab26234fc Discover a texrra-web sibling checkout
The repository is checked out as texrra-engine next to texrra-web, but
find_web_root only looked for ../web and ./web, so a plain
`cargo run --release -- serve examples/hello.tex 4174` served the "frontend not
found" page. The search now also accepts ../texrra-web and ./texrra-web, and the
startup warning names the sibling checkout. README and STATUS document the
accepted layouts.

Verified without TEXRRA_WEB_DIR: the server printed "Serving the web frontend
from ../texrra-web" and GET / returned the editor index.
2026-10-27 12:56:13 +08:00
gloamxun 254fd4a9a1 Fix heading/float block boundaries and record the web trial
The curated trial exposed two parser losses: a heading followed on the next
line by body text dropped the body, and consecutive figure/table/equation
blocks without blank lines swallowed each other. Headings are now separated
from following text and later headings, and the block splitter understands
display environments plus headings, so article-basic keeps its body, figure,
table and equation while arxiv-template moves from 2 to the expected 3 pages.

WEB_ROUTE_D_EXPERIMENT.md now records the three-project results (article-basic,
unicode-mixed, arxiv-template), the Edge smoke test, the go/no-go and the
updated P0 backlog: SVG preview image embedding, .bib data, vector figures and
table-cell math. Test counts move to 1065 (431 engine, 442 core, 64 server).
2026-10-27 12:46:48 +08:00
gloamxun 8d70868781 Record the web contract commit baseline 2026-10-27 12:24:52 +08:00
gloamxun 21943410e9 Refresh route-D counts and engine header note 2026-10-27 12:24:34 +08:00
gloamxun 1058122388 Add route-D web contract and experiment matrix
Route-D preview JSON now reports durationMs on the flat, project and edit
paths, and project preview/PDF responses carry X-Preview-Engine (route-d or
v1), including cache hits and silent fallback. The server tests assert the
headers, the duration field and both PDF engines.

docs/WEB_ROUTE_D_EXPERIMENT.md records the audit verdict, the initial contract
probe, the supported/gap matrix, the three-project trial plan and the
prioritised backlog; ROUTE_D_STATUS.md links to it and the test counts move to
1063.
2026-10-27 12:23:04 +08:00
gloamxun c49afbdecb Record the final verification run
The status document now records the final full run at commit a500236:
./scripts/verify-route-d.sh is fmt-clean and passes 1062 tests (442 core/route-D
unit, 429 engine binary, 63 server, 71 v1, 42 oracle, 10 route-D integration, 4
and 1).

No code changes in this increment.
2026-10-27 04:13:28 +08:00
gloamxun a50023691b Parenthesise eqref for non-equation labels
\eqref on a section, figure or table label rendered the bare number because the
section-reference pass shared the \ref replacement. It now wraps the value in
parentheses, matching amsmath's equation form; equation labels already took the
parenthesised path in the equation pass.

A preview test labels a section and checks "See (1)." with no warnings.
2026-10-27 04:11:45 +08:00
gloamxun 263fa36fb5 Activate dormant tests and clear route-D warnings
Three test functions in texrra-tex-core (PDF metadata, Type1 outline embedding
and \noalign row glue) were missing their #[test] attribute and only produced
dead-code warnings. With the attributes added they pass and raise the core suite
from 439 to 442 tests. The unused `mut` on the PDF entry point geometry is gone
too, leaving no route-D/PDF/lib compiler warnings in `cargo check
--workspace --all-targets`.
2026-10-27 04:09:26 +08:00
gloamxun c14c374d5d Consume FloatBarrier and balance
\FloatBarrier (placeins) and \balance (balance) were unsupported and could leak
into the body. Both are now removed in the body pass: flush requests are a
no-op because floats are already placed in source order, and column balancing
has no meaning in the single-column engine.

A preview test puts both commands between two paragraphs and checks the text
with no warnings or leaked commands.
2026-10-27 04:06:17 +08:00
gloamxun c89f972a25 Alias colours with colorlet
\colorlet{alias}{source} was unsupported, so a colour alias used by
\textcolor or \color leaked. The page-geometry pass now reads both brace groups,
looks the source up in the custom colours and the standard named colours, and
records the alias with the same RGB value.

A preview test defines an HTML colour, aliases it, colours a word with the
alias, and checks the RGB value reaches the SVG with no warnings.
2026-10-27 04:04:14 +08:00
gloamxun 7975671882 Give titlepage its own pages
A titlepage environment was unsupported, so a front-page block stayed in the
main flow. A body pass now replaces its begin and end with \newpage breaks
(trimming a leading break when the title page opens the document), and the
environment name counts as supported. The title layout itself remains the
content's responsibility.

A preview test puts a title page before the body and checks two pages with both
texts and no warnings.
2026-10-27 04:01:59 +08:00
gloamxun 0075352832 Record the route-D scope assessment
The status document now states what the handoff closes: the recovered commits,
the textual token/catcode engine, measured saveboxes, nested/valign tables,
NFSS/font coverage and the route-D service default, each backed by tests and
docs. It also makes clear that the Known limits are architectural extensions
that leave the corpus, oracle suite and service defaults green.

No code changes; verification stays at 1055 tests and the recorded live smoke
test.
2026-10-27 03:59:27 +08:00
gloamxun dff0483bca Add a verification script and record live smoke evidence
scripts/verify-route-d.sh runs cargo fmt --check and the full offline workspace
test suite from the repository root. The status document points at the script
and records a live check of the debug server: POST /preview answered 200 with
X-Preview-Engine: route-d, one page and no warnings, and POST /api/route-d/pdf
answered 200 with a PDF body.
2026-10-27 03:58:44 +08:00
gloamxun f71a12573e Consume multicols wrappers
A multicols environment was unsupported, so a template wrapping its body in
\begin{multicols}{2} leaked the wrapper and its count. A body pass now strips the
begin form (optional arguments and the column count) and the matching end, and
marks both environment names as supported; the body lays out at the full
single-column measure because the engine has no column balancing.

A preview test wraps two paragraphs in multicols{2} and checks both render with
no warnings and no leaked command.
2026-10-27 03:52:30 +08:00
gloamxun 59ba5ac247 Render the keywords environment
A keywords environment was unsupported, so classes that print their keyword
list as an environment leaked the wrapper. A body pass now finds the block,
replaces \sep with ", ", and emits a bold "Keywords:" lead-in followed by the
entries; the environment name counts as supported.

A preview test renders "alpha\sep beta" as "Keywords: alpha, beta" with no
warnings.
2026-10-27 03:50:14 +08:00
gloamxun 58c35c85b9 Resolve cref on equation labels
cleveref on an equation label still leaked: equation labels are resolved before
the section reference pass, so \cref/\Cref never saw them. The equation pass now
also rewrites both forms to "Equation <n>" in blocks and equation rows, matching
the existing \autoref handling.

The equation autoref test now also renders \cref{eq:a} and expects both
references.
2026-10-27 03:48:08 +08:00
gloamxun a451df620c Resolve cleveref cref lists
\cref and \Cref were unsupported, so documents using cleveref leaked the
command. The reference pass now scans both commands, splits the comma-separated
keys, looks each up in the existing label and kind tables, and joins them as
"Section 1 and Figure 1"; \Cref capitalises each kind and unknown keys become
"??".

A preview test labels a section and a figure and checks both forms with no
warnings.
2026-10-27 03:46:11 +08:00
gloamxun 25c7659afe Expand the common siunitx commands
\SI/\qty, \SIrange, \num and \si were unsupported, so numbers and units leaked
as command text. A body pass now reads their braced arguments, normalizes the
number (dropping thin spaces and grouping braces) and maps common unit macros to
short symbols: metre/meter to m, second to s, kilogram to kg, per to /, squared
and cubed to superscripts, and the kilo/milli/micro/nano/centi prefixes.

A preview test renders "3.5 m", "2 km/s", "1000" and a bare "m" with no
warnings.
2026-10-27 03:43:35 +08:00
gloamxun e53ce3b601 Support the appendices environment
The appendices environment was reported as unsupported, so appendix sections
kept main-matter numbering. A body pass now replaces \begin{appendices} with a
blank-line-padded \appendix (so it becomes its own block and the sectioning pass
sees it) and drops \end{appendices}; the environment name counts as supported.

A preview test puts a section inside appendices and checks "1 Main" and
"A Extra" render with no warnings.
2026-10-27 03:41:11 +08:00
gloamxun 82c3e24d18 Accept columnwidth and paper dimensions in graphics options
parse_image_length only recognized \textwidth, \linewidth, \hsize, \textheight
and \vsize, so width=\columnwidth (common in two-column templates) produced no
size. The list now also accepts \columnwidth and \paperwidth as widths and
\paperheight as a height, each scaling the configured measure.

The graphics sizing test gains a width=0.5\columnwidth case matching the
\textwidth result.
2026-10-27 03:38:44 +08:00
gloamxun f5ddad30a2 Support the usefont NFSS form
\usefont{encoding}{family}{series}{shape} was unsupported, so a class using the
low-level font selection left its arguments in the text. The inline NFSS parser
now recognizes the four braced groups, maps the family code through the same
cmss/lmss/phv/pcr/cmtt table as \fontfamily, and sets bold/italic/slanted/small
caps from the series and shape.

The existing nfss test gains an assertion that
\usefont{T1}{cmss}{b}{n} selects SansBold.
2026-10-27 03:36:08 +08:00
gloamxun c3aa4e9dad Parenthesise tag text like LaTeX
\tag{B} stored the bare text and the renderer painted "B", while LaTeX draws
"(B)"; \tag* is the bare form. Tag extraction now wraps the non-starred argument
in parentheses and leaves the starred form alone, for both equation rows and
whole equations.

The existing tag tests expect "(B)"/"(C)", and a new preview test checks the
parentheses glyphs around "A" with no warnings.
2026-10-27 03:33:21 +08:00
gloamxun 3b28ea6693 Accept starred equation tags
\tag* was not parsed: the tag extraction only looked for \tag, so the starred
form stayed in the formula. Both the row pass and the block pass now try
\tag*{...} before \tag{...}, so the tag text is removed from the math and used
as the equation tag.

A preview test tags an equation with \tag*{A} and checks the glyph appears with
no warnings and no leaked command.
2026-10-27 03:30:57 +08:00
gloamxun a5871774ec Resolve autoref on equation labels
\autoref{...} pointing at an equation fell through to "??" because equation
labels are resolved during the equation numbering pass and never reached the
section-reference kind table. That pass now also rewrites \autoref to
"Equation <n>" in both a math block and its equation rows.

A preview test labels an equation and checks "See Equation 1." with no
warnings.
2026-10-27 03:28:22 +08:00
gloamxun 4d713df3dd Resolve nameref for figure captions
\nameref fell back to the number for float labels because only headings fed the
title table. The float numbering pass now records each label with its raw
caption text, and that table is merged into the same title map nameref reads, so
\nameref{fig:a} returns "A plot" while \autoref keeps "Figure 1".

A preview test labels a figure with \caption{A plot} and checks
"See A plot and Figure 1." with no warnings.
2026-10-27 03:26:04 +08:00
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
gloamxun 1d1009395b Offset counters with stepcounter
\stepcounter and \refstepcounter were unsupported, so a document that advanced a
counter before its next heading kept the old number. The geometry pass consumes
both commands and bumps the named counter in the stored counter table (creating
it at one when it was absent); page counters keep their dedicated
\addtocounter page handling.

A unit test steps section before \section{Introduction} and checks the heading
renders as "2 Introduction".
2026-10-27 03:21:48 +08:00
gloamxun 4068366190 Support xrightarrow and xleftarrow
The amsmath extensible arrows were unknown, so their labels fell back to plain
text. The math parser now reads \xrightarrow/\xleftarrow, an optional [below]
label, and the above label, and builds nested Stack atoms around the arrow
symbol: above stacks upward, an optional below label stacks downward.

The math test compares the bare arrow with the labeled form (width/height grow)
and with the two-label form (total height plus depth grows).
2026-10-27 03:18:20 +08:00
gloamxun 8307fc8918 Map boldsymbol to the bold math alphabet
\boldsymbol and \bm were unknown math commands, so a bold symbol fell back to
the default layout. Both names now select the same bold alphabet as \mathbf;
symbol-heavy arguments still use the regular symbol metrics, which is the
existing alphabet approximation.

A math test compares \boldsymbol{x} with \mathbf{x} for equal width and height.
2026-10-27 03:15:16 +08:00
gloamxun 3df130a6b3 Use short headings in running heads
A section's optional [short] title already replaced the long title in the table
of contents, but the running heads kept the long title. When recording heading
units, the document now prefers heading_short (with its number) and falls back
to the rendered heading text, so headings/myheadings and the fancy \rightmark
fallback show the short form.

A headings-style test with \section[Short]{A long title} checks the header says
"1 SHORT" and not the long title.
2026-10-27 03:11:56 +08:00
gloamxun 0e386f8fdc Respect myheadings marks-only headers
\pagestyle{myheadings} behaved exactly like headings, so it filled the left
header with the current numbered heading. The geometry now records myheadings
separately; in that style the left header shows the explicit \markboth/\markright
text when present and stays empty otherwise, while headings keeps using the
current heading title. The page number behavior is unchanged.

A two-page test sets myheadings and \markright{Custom mark}, then checks the
header shows "CUSTOM MARK" and not "1 INTRODUCTION".
2026-10-27 03:09:16 +08:00
gloamxun 4ad15f1f0b Give standalone labels their heading title
A \label on its own paragraph after a heading resolved \ref and \autoref, but
\nameref fell back to the number because the label-to-title table only recorded
labels taken from heading text. Section numbering now tracks the latest heading
title and records it for label-only paragraphs (and ordinary paragraphs that
carry a label), so \nameref returns the title for those labels too.

A preview test puts \label on its own line after \section, then checks
"Introduction and Section 1" with no warnings.
2026-10-27 03:07:12 +08:00
gloamxun abf5e90578 Capture tabulars wrapped in resizebox
A \resizebox or \scalebox around a tabular left the wrapper in the body and the
tabular capture swallowed the caption and \end{table}, so scaled tables were
lost. A source pass now removes such wrappers when their content contains a
table, longtable or table environment (and clears a leading % comment), leaving
the tabular at top level where the existing capture sees it; wrappers around
ordinary text stay for the later text pass.

A preview test wraps a two-row tabular in \resizebox inside a table and checks
"Table 1: Resized" plus the cell text with no warnings.
2026-10-27 03:05:03 +08:00
gloamxun e8f7e37cf7 Pin the corpus page counts
The corpus guard only checked that each document produced at least one page.
It now asserts the exact counts (hello 1, boxes 1, compat 1, arXiv template 2)
alongside the empty warnings array, so a layout regression that drops or adds a
page fails the server test even when no warning is emitted.

The status document's verification paragraph mentions the exact-count check.
2026-10-27 03:02:30 +08:00
gloamxun 7fbcb326d5 Keep the content of scaled box wrappers
\scalebox, \resizebox, \rotatebox and \raisebox were unsupported, so a wrapped
graphic or table could leak its command text. A body pass now parses each
wrapper's numeric/optional arguments and replaces the whole construct with its
content, leaving the content at natural size and position because the engine
has no display-list transform.

A test wraps four fragments in the four commands and checks the visible text
concatenates with no warnings and no leaked command names.
2026-10-27 02:59:19 +08:00
gloamxun dc9428e87e Honour explicit par paragraph breaks
An explicit \par inside a block stayed in the paragraph text and could leak as
an unsupported command. The final body pass now turns a standalone \par token
(not a \par... command prefix) into a blank line, so the block splitter starts a
new paragraph at that point.

A unit test feeds "First line.\par Second line." through geometry_and_body and
checks it splits into two paragraphs.
2026-10-27 02:56:28 +08:00
gloamxun 1227d82f02 Consume mark commands written inside running text
The line-start forms of \markboth and \markright were handled, but an inline
"Body \markright{Short title} text." leaked the command. A body pass now finds
either command anywhere, records the left/right marks for the running heads,
and removes the command from the text (malformed brackets are left untouched).

A fancy-header test puts \markright inside a paragraph and checks the header
shows "Short title" with no warnings and no leaked command.
2026-10-27 02:53:27 +08:00
gloamxun 5dda1a948a Give autoref the right kind prefix
\autoref always wrote "Section <number>", even for figure, table or theorem
labels. The reference passes now record a kind alongside each label: sections
use "Section", floats use their caption prefix (Figure/Table), and theorems use
their display name; resolve_section_refs builds \autoref from that kind, falling
back to "Section" for unknown labels.

A preview test labels a figure, refers to it with \autoref, and checks "Figure 1"
with no warnings.
2026-10-27 02:51:11 +08:00
gloamxun 48e86fb214 Close proof bodies with a QED symbol
A proof environment stopped at its last body line, without the boxed QED mark
LaTeX's amsthm draws. Proof bodies now get a trailing "□" (an explicit
\qedhere is consumed first), so the rendered result matches the usual proof
ending.

A preview test wraps "Because it follows." in a proof and checks the text ends
with the symbol and no warnings are reported.
2026-10-27 02:48:52 +08:00
gloamxun 1e4eb2d5ab Fall back to the current heading for fancy marks
Running heads expanded \leftmark/\rightmark only from explicit
\markboth/\markright, so a fancy header using \rightmark stayed empty when the
document never set a mark. Document now exposes the per-page heading list from
the previous increment, and running_head_text falls back to the current numbered
heading (uppercased) when no explicit left/right mark is configured.

A two-page test with \rhead{\rightmark} and a section checks "1 INTRODUCTION"
appears in the header with no warnings.
2026-10-27 02:46:34 +08:00
gloamxun 9da0f136a4 Show the current heading in headings-style headers
The headings page style only painted the page number. Document now records its
heading units (unit index and title) during layout, and a page_headings helper
carries the latest heading from page to page through the page sources. The
running-head pass uses that list in headings style: the numbered heading title
is uppercased at the left of the header and the page number stays right-aligned,
with the first page still plain.

The headings test gains a section and checks "1 INTRODUCTION" sits at the left
of the header baseline.
2026-10-27 02:44:14 +08:00
gloamxun ae810867f7 Cover nameref with a label on the next line
The heading-label fix and the title table interact: a label directly under
\section (no blank line) must still resolve \nameref to the heading title and
\autoref to "Section <n>". A preview test now pins that combination, rendering
"Introduction and Section 1" with no warnings and no "??".

No production code changed in this increment.
2026-10-27 02:40:54 +08:00
gloamxun 22d5332658 Put the page number in the header for headings style
\pagestyle{headings} and {myheadings} were ignored, leaving the number in the
footer. The parser now records the headings styles; the running-head pass paints
a right-aligned 9pt page number at the head baseline on pages after the first
(LaTeX's plain first page), and the footer number is skipped for those styles.
Section titles in the header are still not modelled.

A two-page preview test checks "2" sits above the body on page 2, right-aligned
past x=400, with no warnings.
2026-10-27 02:38:26 +08:00
gloamxun 9f642a2bbd Render custom bibitem labels
The optional label of \bibitem[Label]{key} was parsed and thrown away, so the
list and citations always used the running number. The extractor now carries the
label in the entry (behind a private marker) and the bibliography list prints
[Label]; citation resolution uses the same label for that key, while unlabeled
entries keep their positional number.

A preview test gives the first entry a label and leaves the second plain,
then checks the list markers and the two citation markers with no warnings.
2026-10-27 02:35:45 +08:00
gloamxun 85d5c87b12 Keep citation notes inside the brackets
An optional note on \cite, \citep or \citet was parsed and discarded. The
citation pass now remembers the first bracket note and appends it inside the
resolved bracket, so \citep[p.~3]{alpha} prints "[1, p. 3]" instead of "[1]"
(the tilde still becomes a space later in the text pipeline).

The existing citation test now asserts the note form; the rest of the unit
suite is unchanged.
2026-10-27 02:32:24 +08:00
gloamxun f05723808c Support explicit footnote numbers
\footnotemark[n] and \footnotetext[n]{...} left the bracket text in the line
and ignored the requested number. The footnote pass now reads an optional
bracketed integer: \footnotemark[n] emits that marker (and advances the counter
to it), while \footnotetext[n] attaches its body to the pending note with that
number, creating the entry when the mark appeared elsewhere in the paragraph.

A test uses mark and text with [7], checks "(7)" and the deferred body render
with no warnings, and that no "[7]" text leaks.
2026-10-27 02:30:01 +08:00
gloamxun d3baa78e1e Attach heading labels that follow on the next line
A \label on the line after \section without a blank line was discarded with the
rest of the text after the heading's closing brace, so \ref printed "??".
heading_command now keeps any immediately following \label groups (allowing
whitespace/newlines) in the heading text, which lets the numbering pass attach
them to that heading; other trailing text is still ignored as before.

A preview test puts \label{sec:intro} directly under \section{Introduction},
refers to it, and checks "See 1." with no warnings and no "??".
2026-10-27 02:27:17 +08:00
gloamxun 723b9e220f Render acknowledgement environments as a heading
The acks, acknowledgments and acknowledgements environments were reported as
unsupported. A body pass now rewrites their \begin into an unnumbered
"Acknowledgments" \section* and drops the matching \end, and the environment
names count as supported so the preview warning stays empty.

A test wraps "Thanks." in \begin{acks}, then checks the heading and body text
render with no warnings and no leaked environment names.
2026-10-27 02:24:23 +08:00
gloamxun 0a4bc0ade5 Handle cleardoublepage and column switches
\cleardoublepage was unsupported and \onecolumn/\twocolumn leaked into the
text. The block splitter now treats \cleardoublepage like \newpage/\clearpage
(it sets the pending page break) and consumes the two column switches, since
the engine lays documents out in a single column.

A test alternates the three commands around First/Second/Third, checks at least
two pages, all three texts present, and no leaked commands or warnings.
2026-10-27 02:21:01 +08:00