Advance native LaTeX execution and preview

This commit is contained in:
gloamxun committed 2026-11-18 22:17:21 +08:00
1 parent 91f9d76b16
commit 2741546ca8
414 files changed
+99872 -933

No files matched your search

+200
View File
@@ -0,0 +1,200 @@
# Native display math transitions — 2026-11-01
2026-11-03: [W3-S2](NATIVE_SPLITTING.md) now extracts migrating marks during actual
display hpack and appends them after the display box before postdisplaypenalty.
Vsplit consumes the original boxes, glue and marks; original math/page/PDF gates
remain green. Workspace1330/0, full format boot false; native page/output/shipout
and remaining W3–W7 consumers are still required. Earlier evidence is historical.
2026-11-03: [W2-S4 native operators and limits](NATIVE_MATH_PROGRAMS.md)
now feed actual display variants/limits/rebox into these transitions. The vlist
oracle has 73 cases (15 added operator cases); old page/quantity/PDF gates and
the new operator PDF/ink gate pass. Latest workspace1311/0; full native format
boot remains false, and W3–W7 are still required. Earlier notes are historical.
Subsequent box/list diagnostic acceptance (2026-11-01): [native inspection](NATIVE_BOX_DIAGNOSTICS.md)
consumes actual showboxbreadth/showboxdepth and original nodes/settings in real
log/terminal output. Full workspace: 1200 passed / 0 failed; 152 exact recursive
lists, 24 paragraph lists, 24 byte-printer cases, 17 CLI tests and five-show/
19-word PDF gate pass. Unchanged LaTeX stops at errorcontextlines (526:1), full
startup false. Compound math/glue inspection and full interaction remain open.
Earlier counts/boundaries below are historical; no font/template fidelity claim.
Subsequent delimiter acceptance (2026-11-01): [native delimiter fields and construction](NATIVE_DELIMITERS.md)
now consumes real delcodes, left/right fields, factor/shortfall and actual TFM
variants/extensible recipes. Full workspace: 1195 passed / 0 failed; 452 exact
DVI cases, code/group readbacks, a 61-word PDF and full-delimiter ink gate pass.
Generic odd-sp fraction/reboxing rounding is corrected. Unchanged LaTeX stops
at showboxbreadth (524:1), full startup false. Earlier counts, boundaries and
unimplemented-left/right/delimiter notes below are historical.
Subsequent font-state/accent acceptance (2026-11-01): [native font integers and accents](NATIVE_FONT_STATE_ACCENTS.md)
now consumes real first-load defaultskewchar and globally mutable skewchar/
hyphenchar in actual mathaccent/discretionary/hyphenation construction. Full
workspace: 1191 passed / 0 failed, 438 accent DVI geometry and 28 mutable-hyphen
timing cases, a 54-word PDF and full-accent ink gate. Unchanged LaTeX stops at
delimiterfactor (523:1), with full format boot still false. Earlier boundaries,
counts and unimplemented-accent/font-integer notes below are historical.
Subsequent font-slot acceptance (2026-11-01): [native font diagnostics](NATIVE_FONT_DIAGNOSTICS.md)
now consumes tracinglostchars/tracingonline using actual TFM/Type1 slots, with
real font predicates, log/terminal delivery and fatal PDF protection. Full
workspace: 1187 passed / 0 failed; prior slice gates remain green. Unchanged
LaTeX now stops at defaultskewchar (522:1), so earlier boundaries/counts on
this page are historical. Full format startup remains false.
The strict Route-D token executor now enters and exits actual display math.
It finishes the preceding paragraph with displaywidowpenalty, converts owned
noads in display style, builds and places a measured horizontal math box, appends
real penalties/skips, and resumes the same paragraph. It uses no source string,
MathAtom adapter, v1 fallback, template placement rule or runtime TeX subprocess.
## Mode, state and lists
engine/display.rs owns the transition context; engine/math.rs still consumes
expanded math tokens and fields. Opening $$ is detected by TeX's raw lookahead
in ordinary horizontal mode. Vertical mode first starts the actual indented
paragraph. Restricted hbox $$ keeps its inline meaning. The second closing
shift is expanded after returning to vertical mode, and is required strictly.
An intervening space or unmatched group is an error. The outer display reports
ifmmode=true and ifinner=false, including inside a vbox; nested fields remain
inner math. Resume reports actual horizontal mode and spacefactor=1000.
Ten additional parameters have actual consumers (55 typed parameters total):
displaywidowpenalty, predisplaypenalty, postdisplaypenalty, abovedisplayskip,
belowdisplayskip, abovedisplayshortskip, belowdisplayshortskip, predisplaysize,
displaywidth and displayindent. INITEX defaults are genuinely zero. The driver
explicitly configures its usual skips/penalties. User assignments use the native
scoped/global/globaldefs state, arithmetic and quantity printing. TeX's internal
fam/display dimension initialization is local independently of globaldefs.
The preceding paragraph chooses displaywidowpenalty as its actual final widow
term; ordinary par still chooses widowpenalty. Club/interline/broken terms retain
their existing consumers. This does not alias two parameter names or retroactively
restyle already-built lines. Display entry preserves hanging indentation and
paragraph state. The display width/indent follow the actual line count and
hangafter/hangindent rules, including negative hangafter.
Predisplaysize is computed from the final line's natural widths and visible
nodes plus the selected text font's actual two-em quad. It does not depend on
rounded glue-setting coordinates. Stretch/shrink before a visible node can
make it max_dimen; empty noindent/resumed lists give -max_dimen, and trailing
fill alone does not change the last visible edge. Unboxed mathematical
characters and their italic correction kerns now remain distinct TextNode
variants. That preserves the genuine visible character boundary (for example
an inline y's 0.35878pt italic kern must not count as its visible right edge).
Grouped/scripted/fraction boxes retain their real boxed visibility. Existing
math dimensions, spacing, penalties and painting remain validated.
Math conversion uses actual assigned CM family resources in initial display
style and disables automatic binop/rel penalties. The resulting list is
naturally hpacked; an overwide list is genuinely repacked to displaywidth with
its actual shrink, glue setting, dimensions, diagnostics and last_badness.
The shift is displayindent + TeX half(displaywidth - packed width). Short skips
are selected exactly when that edge exceeds predisplaysize. User assignments
inside the display affect this conversion before group restoration.
The native vertical list receives predisplaypenalty (including zero), the
selected above skip, append-to-vlist's actual baseline/line glue and shifted
math box, postdisplaypenalty (including zero), and the selected below skip.
These nodes participate in actual pagination. Glue does not reset prevdepth;
the measured display depth drives subsequent baseline glue. NativeBox now
owns its vertical-list horizontal shift; vpack width measurement, nested box
painting and root export consume the same value. Hanging line shifts also
contribute to actual vpack width.
Resume restores the math group first, increments the paragraph line context by
three, and starts an unindented continuation without adding parskip. It reads
the restored minima/font environment and consumes TeX's one optional expanded
space. Consecutive displays and explicit par/new-paragraph boundaries retain
their distinct behavior. Traces retain actual widow choice, prior line context,
pre-display size, measured display box and parameter snapshots. These traces
are not resumable native checkpoints or stable format images.
## Actual page packaging
The independent display page oracle exposed a general PageBuilder defect:
a forced penalty at an already overfull point discarded earlier legal fits.
PageBuilder now uses TeX awful_bad and stops at the first overfull legal break,
or at a forced break, then outputs the best candidate seen so far. Prohibited
penalties and following glue remain unavailable breakpoints. The previous
saturated-underfull deplorable=100000 cost rule remains intact.
The three-page PDF oracle also exposed a native host-policy mismatch: ragged
page export left finite display stretch unused on forced pages. Strict native
export now uses actual page glue packaging; terminal infinite fill keeps the
last page natural. No glyph offset or fixture-specific page adjustment was
introduced. Page goal/topskip/maxdepth/paper/origin are still the explicit host
canvas, not newly advertised native page primitives. Complete native page /
output / box255 / shipout / whatsit execution remains future work.
## Acceptance
- Five display integration tests contain **58 real pdfTeX INITEX vlist cases**
(all box/glue/shift dimensions <=1sp and penalties exact), **36 actual page-
ownership cases**, and **24 exact quantity/mode/pack cases**. They cover
display-widow selection, normal/short skip boundaries, zero/forced/prohibited
penalties, nested boxes, empty/consecutive displays, positive/negative hanging
indentation, restored scopes/globaldefs, optional-space/macro-shift handling,
scripts/fractions, actual pre-display widths and display hpack badness.
- Native and reference display.tex each produce **three pages and 97 words**
with identical page-local order. Max word-box errors: xMin 0.005490, xMax
0.012337, yMin 0.000278 and yMax 0.000078bp; the original 0.02bp gate is unchanged.
All three raster pages were inspected. The prior six-page interline, inline
math, paragraph and nested-box PDF gates remain green.
- Complete frozen workspace: **1182 passed / 0 failed**, including 15 CLI tests
(native_execution 12, native_job_io 3). Release, fmt/diff and math D pass;
math D remains three pages, rule y error +0.1035625bp and identical 144dpi ink
bounds. The prior 100 interline vlist / 64 page cases, 205 box, 119 paragraph,
117 math geometry/list / 88 math break, 90 token, 101 quantity and 12 filesystem
comparisons, actual math pack-state and shipout-I/O oracles remain covered.
~~~sh
cargo test -p texrra-tex-core --offline --test execution_display -- --nocapture
cargo test --workspace --offline -- --test-threads=1
cargo build --release --offline
python3 scripts/check-native-paragraphs.py --binary target/release/texrra \
--fixture examples/native-bootstrap/display.tex --expected-pages 3 \
--output-dir /tmp/texrra-native-display/display \
--json /tmp/texrra-native-display/display/pdf-oracle.json
python3 scripts/probe-native-format.py --binary target/release/texrra \
--texmf /usr/share/texlive/texmf-dist \
--json /tmp/texrra-native-display/format-probe-final.json
~~~
Final evidence: /tmp/texrra-native-display/ (five PDF audits, three-page raster,
format-probe-final.json, arxiv-regression.pdf and math-regression.json).
Logs: /tmp/texrra-native-display-accepted-workspace.log and
/tmp/texrra-native-display-accepted-release.log. Earlier debug runs exposed
and then resolved the page-packaging mismatch; only final accepted evidence
certifies this implementation.
Two historical layout tests expected the literal month October while using the
wall clock. Their own test inputs now declare October 31, 2026 explicitly,
keeping their existing reference assertions reproducible across month changes.
Production date handling, native job time and the source template are unchanged.
The month-boundary failure log remains under month-boundary-workspace.log.
## Format boundary and remaining scope
Unchanged, entry-SHA-pinned LaTeX2e 2025-11-01 now advances from
latex.ltx:502:1 displaywidowpenalty through broken/predisplay and existing
paragraph parameters to **508:1, missing tracinglostchars**. Actual auxiliary
timestamp write/read and the source's directory checks still execute.
format_boot_passed remains false. No format source, guard or version marker
was edited. Only the entry is pinned; complete dependencies/fonts remain open.
Next connect tracinglostchars to real missing-glyph diagnostics and actual font
resource/state consumers, then continue the untouched format source. Do not
register an inert tracing flag or substitute requested fonts. General font
identifiers/sizes/fontdimen/hyphenchar/skewchar, TFM/VF/encoding/map closure,
NFSS/fd/cls/sty and XeTeX shaping remain required. The accepted CM text/math
slice does not close the existing Nimbus/SFTT versus Liberation template gap.
This display slice is unnumbered. Equation numbers/leqno, alignments, display-
style operator variants/limits, delimiters/radicals/accents/mathchoice, boxed
math fields, full ligature/reboxing/fraction edge coverage, everymath/everydisplay,
full language/page/output behavior and realtime checkpoints remain open.
Unsupported native commands error; selected display skips with negative
flexibility or infinite shrink error instead of being silently changed.
HTTP/project endpoints still use the transitional frontend. Their accepted
math D gate is separate; native display never falls back to that frontend.