Commit Graph
675 Commits
Author SHA1 Message Date
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
gloamxun c25c38f16a Resolve running marks in fancy headers
\markboth/\markright and the \leftmark/\rightmark placeholders were
unsupported. The page-geometry pass now consumes those mark assignments and
records the last left/right mark; the running-head text expands \leftmark and
\rightmark from that record (document-wide, not per page) before scrubbing, so
a fancy header or footer can carry the current short title.

A test sets \pagestyle{fancy}, \fancyhead[R]{\rightmark} and
\markboth{Left title}{Right title}, then checks the header text is
"Right title" with no warnings and no leaked \rightmark.
2026-10-27 02:18:11 +08:00
gloamxun 0728d78b29 Resolve nameref to heading titles
Section numbering now also records the heading title for each label: a
number_sections_with_titles variant fills a titles table (the existing
number_sections wrapper keeps its signature for tests), and
resolve_section_refs takes that table. \nameref{label} becomes the heading
title, falling back to the number when no title was recorded, while \autoref
keeps producing "Section <number>"; unresolved forms become "??".

A preview test labels a heading inside its braces and renders \ref, \autoref
and \nameref together as "1 and Section 1 and Introduction" with no warnings.
2026-10-27 02:15:13 +08:00
gloamxun c399481c6a Resolve autoref to its section number
\autoref was unsupported and leaked. The section-reference pass now rewrites
\autoref{label} to "Section <number>" using the same label table as \ref, and
unresolved autorefs become "??" with the other reference commands.

A preview test labels a heading inside its braces
(\section{Introduction\label{sec:intro}}), shows \ref and \autoref side by
side, and checks "1 and Section 1" with no warnings.
2026-10-27 02:12:21 +08:00
gloamxun 6139621653 Consume caption and numbering declarations
\captionsetup, \numberwithin and \DeclareCaption were unsupported and could
leak into the body. The page-geometry pass now consumes those declaration lines
(the caption styling and equation-number scoping are not modelled), in the
preamble and in the body alike.

A preview test declares \captionsetup (plain and with [figure]) and
\numberwithin before and inside the document, then checks "Text." renders with
no warnings and no leaked declarations.
2026-10-27 02:08:59 +08:00
gloamxun ebb178bff5 Reserve invisible space for phantom commands
Text-mode \phantom and \hphantom were unsupported. A text-stage pass measures
the scrubbed argument with the Roman metrics and replaces the command with
\hspace of that width, so the glyphs are omitted but the line keeps their
footprint; \vphantom contributes no horizontal material.

A test renders "A\phantom{wide}B and \vphantom{XX}C and \hphantom{QQ}D." and
checks "AB and C and D." with no warnings and none of the hidden text.
2026-10-27 02:06:20 +08:00
gloamxun 5fbcc34ddd Keep hyperref command labels
\hyperref[label]{text}, \hyperlink{name}{text} and \hypertarget{name}{text}
were unsupported and leaked as text. A text-stage pass now drops the link
machinery and keeps the visible label, accepting the optional [label] argument
of \hyperref and the braced target of the other two; internal PDF destinations
are not modelled.

A preview test uses all three forms and checks "the intro", "linked" and
"anchor" with no warnings and no leaked command names.
2026-10-27 02:00:35 +08:00
gloamxun 6c6963cac7 Support footnotemark and footnotetext
\footnotemark and \footnotetext were unsupported, so deferring a note body was
impossible. The footnote numbering pass now selects among \footnote,
\footnotemark and \footnotetext (longest name first so the prefix cannot win):
\footnotemark advances the counter, emits the numbered reference and records an
empty note for the number; \footnotetext fills that pending note with its body
and leaves no text in the line; the remaining text is appended once.

A test pairs a mark and its text in one paragraph, checks the page carries
"(1)" and "Deferred note." with no warnings, and that neither command leaks.
2026-10-27 01:58:22 +08:00
gloamxun 53a299bd58 Honour protect in edef but expand it normally
\protect was just a no-op token, so \edef\b{\protect\a} expanded \a at
definition time. In an edef-style pass the expander now copies \protect and the
following token unchanged (so the stored body keeps the protected command); in
the ordinary document pass it drops \protect and lets the token expand as
LaTeX does when the text is typeset.

A test defines a=A, \edef b={\protect\a}, redefines a=C, and checks both \b and
a literal \protect\a print C with no warnings.
2026-10-27 01:54:13 +08:00
gloamxun c3ae52452d Resolve csname targets with arguments
\csname foo\endcsname stopped after looking up a zero-argument macro; a
parameterised target was left unresolved. After the zero-argument fast path,
build a synthetic command from the resolved name plus the text following
\endcsname and run the normal macro lookup, so arguments/defaults/delimited
parameter text are consumed exactly as for a literal \foo, and only the bytes
belonging to the csname construct are charged to the caller.

A test defines \foo#1{[#1]} and prints both \csname foo\endcsname{x} and
\csname foo\endcsname{y} as "[x] and [y]" with no warnings.
2026-10-27 01:51:29 +08:00
gloamxun c3e02f0586 Make global definitions override group shadows
A group-local \def stayed visible after a later \gdef of the same name because
scoped lookup preferred the newest scope entry, and an inline \global\def was
unsupported. Route \gdef/\xdef and \global\def/\global\let/\global\chardef
through an upsert that removes same-name entries from every live scope before
updating the global table, so the global meaning wins inside the group and
after it.

A test defines a group-local L, replaces it with G via \gdef inside the group,
and checks the group prints G and the following \a prints G; an
inline \global\def also expands.
2026-10-27 01:49:17 +08:00
gloamxun 16b61cd368 Freeze unexpanded tokens through an edef
\unexpanded passed its text straight through, so \edef\b{\unexpanded{\a}}
expanded \a at definition time. Split the expander into an inner pass with a
freeze flag: the edef-style wrapper protects each backslash in \unexpanded's
argument with the existing no-expand marker, which the pass restores on the way
out, while the normal document pass still writes the text through so it expands
at use time.

A test defines a=A, \edef b={\unexpanded{\a}}, redefines a=C, and checks \b
prints C with no warnings; the earlier \expanded/\unexpanded/\detokenize test
still passes.
2026-10-27 01:47:08 +08:00
gloamxun 4024fa7435 Add the route-D status handoff and fix README defaults 2026-10-27 01:43:17 +08:00
gloamxun 8bdeffa646 Add expanded, unexpanded and detokenize
Three expansion primitives class files use were unsupported. \expanded{...}
runs the argument through the current macro table and scopes immediately;
\unexpanded{...} passes the text through unchanged (normal typesetting
semantics; the edef freeze is not modelled); \detokenize{...} prints the text
literally through the same private-use escaping as \string.

A preview test expands \a, passes \a through unexpanded and detokenizes it,
checking "Hi and Hi and \\a." with no warnings.
2026-10-27 01:41:52 +08:00
gloamxun 28aed153fe Guard corpus previews against warnings
The warning-free corpus sweep was only a manual check. Add a server test that
previews examples/hello.tex, boxes.tex, compat.tex and the arXiv template
through /api/route-d/preview and asserts each returns 200, at least one page
and an empty warnings array, so the corpus guard runs with the normal suite.
2026-10-27 01:39:32 +08:00
gloamxun 88a03ec1a1 Scale inline math proportionally
Inline math in a 12pt paragraph kept 10pt glyphs because paint_math advances
with 10pt metrics. Paint the math atom into a temporary display list at the
10pt baseline and scale that list as a unit (text sizes and positions, rule
widths/heights, line endpoints) to the paragraph size before translating it to
the baseline. The box no longer pins its size, so a scaled math glyph now
reports font-size 12.000 in a 12pt paragraph.

The twelve-point test now also asserts that an italic math glyph is rendered at
the paragraph size; the sized-paragraph test still expects a math box and no
literal dollars.
2026-10-27 01:36:59 +08:00
gloamxun b3fbbc8dda Render inline math in sized paragraphs
Inline math returned None whenever the paragraph base size was not 10pt, so a
12pt or \large paragraph printed its dollar delimiters literally. Keep the math
segment at every size: the box width still scales with the paragraph, while the
math glyphs are pinned to the 10pt metric baseline by setting the box's size
field, so paint positions and glyph sizes stay consistent (slightly smaller
than the surrounding text, which is documented).

The old sized-paragraph test now expects a math box and no literal dollars; a
new 12pt preview test checks italic math glyphs and no "$" with no warnings.
2026-10-27 01:34:07 +08:00
gloamxun 65a132d7b1 Handle parbox, orcidlink and a bare hrule
The last three corpus warnings: \parbox becomes an \mbox so the existing box
handling keeps its content (width wrapping is not modelled); \orcidlink{id}
becomes a hyperlink labelled ORCID; and a standalone \hrule becomes the same
here-float rule block as \rule, with the width left unset so the page builder
uses the current line width and a 0.4pt height.

The corpus sweep now reports 0 warnings for examples/hello.tex, boxes.tex,
compat.tex and the arXiv template.

A test previews parbox content, the ORCID link label and a bare hrule with no
warnings and no leaked commands.
2026-10-27 01:30:37 +08:00
gloamxun 93ecf76ea3 Clean inline spacing and guillemet text
A corpus sweep of examples/ and the arXiv fixture showed six warnings in
hello/compat and four in boxes: guillemet symbols, inline \vspace*, \samepage
and inline \smallskip/\bigskip. Add the four guillemet commands to the
text-symbol table and strip spacing commands that survive into running text
(their standalone forms already became vertical glue items, so only inline
leftovers are removed). The sweep is now 2/2/3 warnings (only \hrule, \parbox
and \orcidlink) and the arXiv fixture stays at zero.

Test: inline spacing, \samepage and guillemets render "ABCD«x»" with no
warnings.
2026-10-27 01:27:15 +08:00
gloamxun 7a9e28d0f4 Transpose valign into a table
\valign had no handler. Add a preprocessing pass that finds \valign{...},
splits the group at \cr, treats each remaining \cr-separated line as one column
(entries split on &), and emits an equivalent tabular with the matrix
transposed; the existing capture then lays it out. Column alignment defaults to
left because the \valign preamble describes vertical alignment here.

A test transposes \valign{\cr a & b & c \cr d & e & f \cr} into two columns and
three rows, checking (a,d) and (c,f).
2026-10-27 01:23:20 +08:00
gloamxun 05e1bd096b Apply the percent catcode when stripping comments
Comments were stripped in a separate pass before canonicalisation, so
\catcode`\%=12 happened too late to make a later percent literal. Move comment
stripping into the canonicalisation pass: it now tracks whether % is a comment
char (default yes), skips to the end of line when it is, and \catcode`\%=12
(or 13) turns that off so later percents reach the text. The source order in
geometry_and_body becomes canonicalise (comments + catcodes) then collapse
definition bodies, and the separate strip_tex_comments call is gone.

A test previews "100% sure" under \catcode`\%=12 and the default commented form
("Hello% hidden" + "world") as "Helloworld" with no warnings.
2026-10-27 01:21:10 +08:00
gloamxun d791e3a0f2 Print macro bodies with meaning
\meaning<token> was unsupported. Expansion now reads the following token and
prints its meaning literally: for a known macro, "macro:" plus its parameter
text (or #1..#n from the argument count) and "->" plus the stored body; for an
undefined control sequence, \relax; for a character, "the character <c>". The
text goes through the same private-use escaping as \string so later passes
cannot re-tokenise it.

A preview test defines \greet#1 and prints \meaning\greet plus
\meaning\missing, checking "macro:#1->Hello #1" and "\relax" with no warnings.
2026-10-27 01:18:49 +08:00
gloamxun 47dcdfec47 Print tokens literally with string
\string<token> was unsupported, so documenting a control sequence expanded it
instead of printing it. The expand loop now reads the following token and emits
its characters without expansion; backslash and braces are replaced by
private-use placeholders that the renderer maps back to the real characters, so
the printed text cannot be re-tokenised and expanded by a later pass.

A preview test defines \foo, prints \string\foo, \string{ and \string}, and
checks the literal "\foo and { and }." with no expansion of \foo and no
warnings.
2026-10-27 01:16:30 +08:00
gloamxun 57424015de Measure image saveboxes from decoded pixels
A savebox whose body was only \includegraphics measured as empty text because
images were attached to the geometry after geometry_and_body had measured the
box. geometry_and_body_with_images now seeds the image map before stripping, so
measure_savebox sees the decoded RasterImage: natural size is pixels at 72 dpi
(65,782 sp per pixel), and explicit width/height options in the optional
argument win, with the other dimension scaled proportionally.

Project preview/PDF paths pass their decoded images into the new entry point;
the flat preview keeps the empty map. The body-definition capture only handles
\newsavebox, so its call passes an empty map too.

A test stores a 100x50 image in \logo and checks the frozen width/height and a
zero depth.
2026-10-27 01:14:02 +08:00
gloamxun 53dcedfea2 Refresh the limits section after thirty increments 2026-10-27 01:10:12 +08:00
gloamxun 2ef284e585 Add token registers
\toks was unsupported, so \newtoks/\toks0={...}/\the\toks0 leaked. Expansion
now carries a token-register table next to the macro table: \newtoks declares a
named register, \toks0={...} and a declared \name={...} store text, and
\the\toks0 or \the\name splice the stored text back into the stream.

A preview test stores Hello in a named register and A in \toks0, then renders
"\the\greet and \the\toks0 B" as "Hello and A B" with no warnings.
2026-10-27 01:08:56 +08:00
gloamxun 9005194c54 Rescan scantokens content through the expander
\scantokens was unsupported and leaked its group. Handle it in the expansion
loop: parse the braced argument, replace the command with the group text (after
the command-end marker so it cannot merge with a preceding control word), and
let the remaining passes re-tokenise and expand it like ordinary source.

A preview test defines \greet, runs \scantokens{\greet world}. and checks
"Hello world." with no warnings and no leaked command.
2026-10-27 01:06:40 +08:00
gloamxun cc00b6332c Correct catcode docs wording 2026-10-27 01:04:43 +08:00
gloamxun 54a0926552 Consume catcode assignments for every character
Only \catcode`\@ assignments were handled; a class file setting the catcode of
# or _ left the assignment in the text. The canonicalisation pass now consumes
any successfully parsed \catcode assignment (backtick, bare or code-point
target), applying the value only to @ (11/12); other targets are recorded by
their consumption but do not change scanning yet, since the scanner still has
a single modelled catcode.

A preview test sets # and _ to 12, then renders "#hash and a_b." with no
warnings and no leaked assignment.
2026-10-27 01:04:23 +08:00
gloamxun b16e5a53e8 Run afterassignment tokens after their assignment
\afterassignment<token> leaked because assignment processing happens in later
passes. Add a rewrite after the body is extracted: find \afterassignment, read
its token, locate the following assignment (a \def/\gdef through
runtime_definition, or the next top-level '=' plus its value token), and move
the command before the assignment's follower so the assignment passes run
first. The queued token stays in the stream for normal expansion.

A preview test queues \hello before \a=5 and checks H appears, Text. still
renders and no \afterassignment leaks.
2026-10-27 01:01:28 +08:00
gloamxun 24d5390d25 Queue aftergroup tokens until the group closes
\aftergroup was unsupported, so class-style deferred setup leaked. Expansion
now keeps a parallel stack of pending token lists: '{' and \begingroup push an
empty list, '}' and \endgroup pop it and append its tokens after the group (the
closing brace is emitted first, then the pending tokens with the command-end
marker so a control word cannot merge with the following text).
\aftergroup<token> queues one token and \aftergroup{...} queues the group body.

A test defines a group-local \a while queueing \aftergroup\a, then checks that
the queued \a runs after the group restores A, giving "AA and !X" with no
warnings.
2026-10-27 00:59:19 +08:00
gloamxun 9d10def2f5 Add futurelet lookahead and defer conditionals
\futurelet\alias\command <token> now binds <token> to \alias without consuming
it: the expand loop parses the alias and command, stores the peeked token as the
alias body, and leaves the command plus token in the stream. Conditional
operands are protected from macro expansion, so \ifdefined and \ifx still see
the names they test, and a token-alias macro whose body is one character
compares equal to that character in \ifx.

Conditionals moved after macro expansion (and before register expansion):
running them first evaluated \ifx inside a not-yet-expanded \def body, and
register expansion turned the \a in \ifnum\a=3 into an assignment. The
expand_macros_mut variant writes its runtime table back so later passes see
\futurelet aliases and runtime definitions.

A test covers \futurelet\next\shownext x printing [x] and an \ifx dispatch that
chooses Y.
2026-10-27 00:56:33 +08:00
gloamxun e48a64da7a Resolve csname during runtime expansion
\csname only worked inside \edef bodies, so a normal macro such as
\def\a{\csname foo\endcsname} leaked the literal construct. Handle it in the
expand loop: read through \endcsname, expand the inner text with the current
runtime table and scopes, look the resulting control sequence up, and splice
its body (nothing when undefined). Macro arguments are not consumed, so a
parameterized target is left alone for now.

A preview test defines \a through \csname, uses both \a and a direct
\csname foo\endcsname, and checks "Z and Z and ." with no warnings.
2026-10-27 00:49:07 +08:00
gloamxun 34d54d91a4 Honor \catcode`\@ assignments
Class files often set the @ catcode directly instead of calling
\makeatletter. Recognise \catcode assignments in the canonicalisation pass for
the @ target: the target may be written with a backtick, bare, or as a code
point, the value must be numeric (11 letter, 12 other) or \active, and the
assignment is consumed and updates the same state \makeatletter toggles.
Assignments for other characters are left untouched so nothing is silently
dropped.

A preview test sets \catcode`\@=11, defines and uses \@foo, and checks "bar"
with no warnings and no leaked assignment.
2026-10-27 00:46:15 +08:00
gloamxun b056b11ba9 Expand parameterized runtime definitions
runtime_definition only accepted \def\name{body}: if the first token after the
name was not '{' it gave up, leaving a body-embedded \def\foo#1{...} to leak as
text. Parse the parameter text before the body with the same helpers the line
capture uses: definition_argument_count for undelimited #1..#n, otherwise
parameter_placeholders plus the raw parameter text for delimited forms. The
returned MacroDefinition carries args/params, so expand_macro_lookup collects
the arguments during expansion.

A preview test defines \add#1 and \pair#1,#2 mid-body and checks "[x]" and
"(a|b)" with no warnings.
2026-10-27 00:43:51 +08:00
gloamxun 619eb19f72 Map fontspec families to engine faces
fontspec declarations were neither consumed nor mapped, so
\newfontfamily\headingfont{...} leaked into the text. Consume \setmainfont,
\setsansfont and \setmonofont (the engine's Roman/Sans/Mono faces stand in for
those choices) and turn \newfontfamily/\renewfontfamily into an alias macro that
switches to the closest NFSS family by name: mono/typewriter/courier to cmtt,
sans/helvetica/arial to cmss, otherwise cmr. Optional bracket options are
skipped.

A preview test declares all four commands, renders \headingfont Sans words. and
checks no warnings, the sans-serif face and no leaked declaration text. Docs
also record that complex scripts (Devanagari, Thai, emoji) still have no shaping
fallback and render as missing glyphs in the PDF.
2026-10-27 00:41:36 +08:00
gloamxun 81da180ab7 Lay out nested tables inside their cell
Nested tabulars were flattened to a text summary before the outer halign
parsed them, so the inner rows never existed as a table. Keep them instead:
strip_page_geometry replaces each nested block with a \texrranested{index}
token and stores the source on the geometry, and tabular_unit resolves the
token into a recursively built inner table attached to the cell. Cell text is
cleared, column widths and row height take the inner table's metrics, and page
splitting remaps nested row indices when it chunks rows.

Halign gains a nested list, refresh_measurements, nested-aware row_height and a
painting branch that translates the inner display list to the cell position at
the row's alignment. The old flattening pass stays as a dead-code fallback.

The nested-table test now checks one stored source, the placeholder token, one
attached 2x2 table in cell (0, 1), an empty outer cell and inner "a"/"d"
painted in the preview SVG.
2026-10-27 00:38:02 +08:00
gloamxun 371f05baaa Default project previews and PDFs to route-D
uses_route_d still treated v1 as the default unless TEXRRA_ENGINE=route-d was
set, so only the flat /preview endpoint had switched. Make route-D the default
there too: an explicit engine parameter still wins, TEXRRA_ENGINE=v1 forces the
old pipeline, and a route-D error now falls through to the v1 compiler instead
of answering 422 (both preview and PDF).

Because route-D follows pdfLaTeX's Letter default for geometry-less documents,
the two server tests that asserted the v1 A4 page now ask for ?engine=v1 or
expect 215.9mm. A new test starts a server without the environment variable and
checks a project preview uses route-D's italic math face with no literal $.
2026-10-27 00:32:45 +08:00
gloamxun a56d441513 Make route-D the default flat preview engine
POST /preview served the v1 pipeline while route-D lived behind /api/route-d
and the project engine switch. Try route_d::preview_json first and keep the v1
compiler as the fallback when route-D rejects the source; ?engine=v1 forces the
old path and the project endpoints are unchanged.

Both paths now answer with an X-Preview-Engine header (route-d or v1) so the
choice is observable, and the server test helper compares header names
case-insensitively because tiny-http lowercases them.

A server test posts a document and checks route-d by default plus v1 when the
query asks for it.
2026-10-27 00:27:59 +08:00
gloamxun 621a8abb92 Make @ a letter only inside makeatletter
The scanner treated @ as a letter everywhere, so \makeatletter was a no-op and
\foo@bar parsed as one command even outside it. Canonicalise the source once,
before captures: in the default state a control word stops at @ (and a marker
keeps later scanners from re-joining the split), between \makeatletter and
\makeatother the name is rewritten with a private-use placeholder that
control_sequence and expand_macro_lookup accept as a letter and normalise back
to @. Grouping saves and restores the state, and route-D's own \@... names plus
the internal \p@/\z@/\protected@edef family stay literal so their handlers keep
matching; markers are stripped from text before shaping.

Tests cover \@foo inside makeatletter, \foo@bar splitting to \foo plus "@bar",
\@ifundefined still working, and a group-local \makeatother.
2026-10-27 00:24:28 +08:00