Commit Graph
720 Commits
Author SHA1 Message Date
gloamxun 1b7baa0257 Capture multi-line macro definitions and mode conditionals
The preamble parser is line-oriented, so a multi-line \newcommand, \def or
\newenvironment contributed only its first line to the macro table while the
remaining body lines fell through to the document text. In the assembled arXiv
source that also swallowed the \begin{document} marker, so the whole class
preamble was laid out as one page of \NeedsTeXFormat/\fancyhf text.

Join definition bodies at balanced braces before stripping: comments are
removed, a `%` line continuation joins without adding a space, and a blank line
becomes \par. Definitions now reach the existing single-line capture whole.

Resolve \ifhmode as true and \ifvmode/\ifmmode as false for the text expansion
path, so class macros such as \and expand.

The arXiv fixture body no longer contains NeedsTeXFormat, fancyhf or ifhmode and
the project preview lays out four pages instead of one; unit tests cover a
multi-line \newcommand/\def and the arXiv preamble containment. Remaining
warnings are now body commands (\maketitle, \thanks, \lipsum, \addvspace and the
footnote machinery), which are separate work.
2026-10-26 23:08:35 +08:00
gloamxun ebf2070295 Run AtBeginDocument setup and newgeometry as preamble
Class files such as the arXiv template set the page block inside
\AtBeginDocument{\newgeometry{...}}. Route-D treated the hook body as document
text, so the setup commands were typeset at the top of page one and the page
measure stayed at its default.

Lift \AtBeginDocument bodies in front of \begin{document}, join a multi-line
\newgeometry argument into one line, and read it through the geometry option
parser. Explicit textheight/textwidth options now win over margins, so
textheight=9in with top=1in keeps 9in instead of recomputing it from the
paper height.

The arXiv project now applies its 6.5in/9in block and no longer reports a
\newgeometry warning; unit tests cover the multi-line hook, the option
precedence, and the no-leak case. A remaining leak from multi-line macro
definitions in the same class file is separate work.
2026-10-26 23:03:37 +08:00
gloamxun 2f9b18c95c Reserve display skips around math
TeX surrounds each display with \abovedisplayskip above and \belowdisplayskip
below, but route-D only reserved the paragraph's own spacing, so displays sat
directly against the surrounding text. Parse the four registers (including the
short forms), default to the article-class 10/11/12pt values, and add them to
the math unit and the unit that follows it.

The glue parser now also accepts the class-file spelling
(`\abovedisplayskip 7\p@ \@plus 2\p@ \@minus 5\p@`), register copies such as
`\belowdisplayskip \abovedisplayskip`, `\z@`/`\p@` dimensions and
space-separated assignments, which clears the display-skip warnings the arXiv
template produced.

A page oracle sets a 45pt above skip and pins the display moving to the second
page exactly as pdfLaTeX lays it out; unit tests cover the defaults, overrides
and the class-file spelling.
2026-10-26 22:49:41 +08:00
gloamxun 8ac2e828df Honour club and widow penalties on paragraph lines
Route-D expanded a paragraph into one node per line without TeX's
\clubpenalty/\widowpenalty, so a page break could orphan the first line or
widow the last. Insert the penalties between line nodes (150 by default, read
from the source registers) and make the page builder reject any penalty of
10000 or more as a breakpoint. Forced -10000 values now break exactly where
pdfLaTeX does; two page oracle fixtures compare per-page text, and unit tests
cover the node order and the forbidden breakpoint.
2026-10-26 22:14:01 +08:00
gloamxun 1bb28cf141 Skip the SIVP test when its project fixture is absent
projects/ is gitignored, so a fresh clone has no projects/_sivp__/sn-article.tex. Return early like the neighbouring front-matter test instead of panicking on the missing file.
2026-10-26 22:03:25 +08:00
gloamxun 83f49db49e Sort oracle word boxes before grouping lines
pdftotext 26 does not always emit words in reading order: wide justified gaps and hyphenated lines interleave words from different baselines, so parse_bbox split one visual line into several. Sort by baseline and then x before grouping. It also reports each word box as the font extent, whose ascent varies with type size; compare display limits by the subscript/superscript baseline gap, which is anchor-free, instead of mixing 7pt box tops with the 10pt base.
2026-10-26 22:03:25 +08:00
gloamxun e09e413892 Break long paragraphs with prefix sums
The line-breaker rescanned items[start..end] for every break pair, so a 900-word paragraph took seconds and the 2,700-word edit fixture took about 30 s. Prefix sums over natural width, stretch, shrink, glue order, box count and the last penalty give each candidate its metrics in O(1); the search now costs O(breakpoints^2) and the same document lays out in about 0.3 s. Add a 900-word regression test and note the change in TEX_CORE.
2026-10-26 22:03:19 +08:00
gloamxun 41c68baa5d Ignore display break hints 2026-10-26 20:37:24 +08:00
gloamxun 7271e2ee12 End table rows with tabularnewline 2026-10-26 20:36:57 +08:00
gloamxun 80a5e8272d Stretch tabular* tables to their target width 2026-10-26 20:36:49 +08:00
gloamxun 3770de0804 Render tabular* by its declared column template 2026-10-26 20:36:43 +08:00
gloamxun 40abb7bef3 Reserve environment definitions declared in the body 2026-10-26 20:36:30 +08:00
gloamxun 0d9ed56a55 Reserve theorem definitions declared in the body 2026-10-26 20:36:21 +08:00
gloamxun 3087a9a116 Reserve saveboxes declared in the body 2026-10-26 20:35:58 +08:00
gloamxun eaebb1edbf Reserve registers declared in the body 2026-10-26 20:35:42 +08:00
gloamxun 13de893c46 Capture body-level newif definitions 2026-10-26 20:35:34 +08:00
gloamxun dc49b92a47 Capture body-level chardef definitions 2026-10-26 20:35:09 +08:00
gloamxun 2408736c5e Capture body-level let aliases 2026-10-26 20:34:44 +08:00
gloamxun 6efb210781 Capture definitions written in the body 2026-10-26 20:34:33 +08:00
gloamxun 1d891b2c6a Verify test server identity before accepting it 2026-10-26 20:34:20 +08:00
gloamxun 7c98c61b7a Ignore preamble-only guards 2026-10-26 20:34:06 +08:00
gloamxun 991498b0e1 Guard definitions with @ifdefinable 2026-10-26 20:33:57 +08:00
gloamxun f6a41c9f59 Expand the checkmark symbol in text 2026-10-26 20:33:49 +08:00
gloamxun 8e884e6db1 Expand parameterised newcolumntype letters 2026-10-26 20:33:43 +08:00
gloamxun 9d57ca604e Expand newcolumntype letters in table specs 2026-10-26 20:33:14 +08:00
gloamxun 97e883f51d Branch on @ifclassloaded for supported classes 2026-10-26 20:33:02 +08:00
gloamxun c9982a7675 Branch on @ifpackageloaded for known packages 2026-10-26 20:32:51 +08:00
gloamxun fce3a3b0a0 Honour optional newenvironment defaults 2026-10-26 20:32:41 +08:00
gloamxun b7d18dff37 Expand punctuation and symbol commands 2026-10-26 20:32:18 +08:00
gloamxun 3a089c6175 Number standalone captionof captions 2026-10-26 20:32:01 +08:00
gloamxun 7d05268983 Keep underline text without the rule 2026-10-26 20:31:45 +08:00
gloamxun f147ccc8c5 Parse array column modifiers and their alignment 2026-10-26 20:31:33 +08:00
gloamxun 71dc8ca59b Treat starred floats as their single-column forms 2026-10-26 20:31:18 +08:00
gloamxun 8ecbd5e720 Centre multirow cells over their rows 2026-10-26 20:31:03 +08:00
gloamxun e039cfb8a9 Report float and equation pages through pageref 2026-10-26 20:30:22 +08:00
gloamxun aa072f58d8 Reserve outer tabcolsep margins around tables 2026-10-26 20:29:51 +08:00
gloamxun 20d23ce68d Record the round-150 handoff 2026-10-26 04:54:57 +08:00
gloamxun b191f7d66c Record the remaining compatibility gaps 2026-10-26 04:52:57 +08:00
gloamxun 20813a6607 Ignore strut commands in running text 2026-10-26 04:52:34 +08:00
gloamxun 22f95c1536 Print character commands by codepoint 2026-10-26 04:50:54 +08:00
gloamxun 2476c1893f Keep leftline arguments flush left 2026-10-26 04:49:10 +08:00
gloamxun 3d33ee9dc3 Flush rightline arguments to the right margin 2026-10-26 04:47:29 +08:00
gloamxun 9aa7198aed Centre centerline arguments 2026-10-26 04:45:58 +08:00
gloamxun f11561f15f Keep raggedright blocks unjustified 2026-10-26 04:44:21 +08:00
gloamxun 337f1f6de6 Centre blocks after a centering declaration 2026-10-26 04:41:31 +08:00
gloamxun 3d1ace51ae Print registers as roman numerals 2026-10-26 04:39:55 +08:00
gloamxun ca433d256d Drop break hints and discretionary hyphens 2026-10-26 04:38:04 +08:00
gloamxun 6c771e0820 Reuse savebox content through usebox 2026-10-26 04:35:42 +08:00
gloamxun c57de1e03c Reserve the named TeX spaces in text 2026-10-26 04:32:40 +08:00
gloamxun 1e8b2367ca Space text with quad and punctuation commands 2026-10-26 04:30:22 +08:00