Skip to content

compiler: accept \text and \boxed in text mode (#834) - #844

Merged
d-q222 merged 3 commits into
mainfrom
muse/ross-text-command
Sep 18, 2026
Merged

d-q222 merged 3 commits into
mainfrom
muse/ross-text-command

Conversation

@d-q222

@d-q222 d-q222 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #834, a false error firing in all 20 documents of a real-user corpus.

amstext.sty defines \text as \ifmmode…\else\mbox\fi, so pdflatex accepts it outside math. FlashTeX raised error[unsupported_feature] with the help "wrap this in math mode" — advice the user cannot act on, because they are already in text mode. The rendered output was already correct (pdftotext matched, pdffonts confirmed \Large was honoured), so this was a red error on correct output.

  • Text-mode \text{...} is now \mbox{...} with no diagnostic.
  • The old path also swallowed single-word arguments — Before\text{ after}After. lost "after". Those now survive, matching the oracle.
  • Text-mode \boxed{...} now draws its frame, reusing the frame-environment path.

Tests: crates/compiler 1,058 passed / 0 failed. New text_mode_commands suite: 8 passed, covering math-mode \text still clean, empty/leading/trailing argument edges, both \boxed cases, and absence of the bad help string.

Oracle: /Library/TeX/texbin/pdflatex (pdfTeX 1.40.29, TeX Live 2026 — not the shipped 2024 logs), preamble \documentclass[11pt]{article} + \usepackage{amsmath,amssymb}; the log confirms amsmath.sty and amstext.sty actually loaded, exit 0, zero ! lines.

⚠️ Lands in crates/compiler, so it does not reach users until the vendor re-pin.

Implemented by a sandboxed Muse lane; committed and published by the Commander after verification.

🤖 Generated with Claude Code

amstext defines \text as \ifmmode...\else\mbox\fi, so pdflatex accepts it
outside math. FlashTeX raised error[unsupported_feature] with the help
"wrap this in math mode" -- advice the user cannot act on, since they are
already in text mode. It fired in all 20 documents of a real-user corpus.

Text-mode \text{...} is now \mbox{...} with no diagnostic. The old path also
swallowed single-word arguments (Before\text{ after}After. lost "after");
those now survive, matching the oracle.

Text-mode \boxed{...} now draws its frame, reusing the frame-environment path.

Measured against /Library/TeX/texbin/pdflatex (pdfTeX 1.40.29, TeX Live 2026)
with \documentclass[11pt]{article} + \usepackage{amsmath,amssymb}; the log
confirms amsmath.sty and amstext.sty actually loaded.

Implementation-Agent: muse-spark-1.3-contributor
Commit-Executor: daniel-parent
Co-authored-by: muse-spark-1.3-contributor <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222 and others added 2 commits September 17, 2026 20:04
Two CI failures, same cause for all three of these PRs.

The branch predated the TAB catcode merge, so its diff against current main
deleted crates/tex-expansion/src/catcode.rs's new lines and the whole of
crates/compiler/tests/tab_whitespace.rs -- merging it would have silently
reverted that fix. Merged origin/main in.

`bundled inventory matches the compiler` failed because the lane regenerated
crates/compiler/supported/supported-latex.json but could not touch apps/**,
which is outside Muse's editable scope, leaving the Mac app's copy stale. The
two must be byte-identical: Completion.Vocabulary decodes the bundled copy and
the editor's completion vocabulary is generated from it, never hand-written.
Ran apps/mac/scripts/sync-supported-latex.sh; --check now passes.

Commit-Executor: daniel-parent
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222
d-q222 merged commit 8017e3d into main Sep 18, 2026
22 checks passed
d-q222 added a commit that referenced this pull request Sep 18, 2026
…facts

#844 (\text/\boxed) and #845 (list) landed on main while this branch was open,
and both touch crates/compiler/src/parser.rs next to this branch's work.

Two genuine source conflicts, resolved structurally rather than by side:

1. The text-mode dispatch arms. This branch adds `"strut"`, main adds `"text"`
   and `"boxed"`. All three belong; kept all three.

2. `fn inline_sets_a_box` (this branch, #843) against `fn inline_text` (main,
   #845). A naive keep-both does NOT work here: this branch's side ends mid-body
   and is closed by the `}` that follows the conflict block, so concatenating the
   two sides produced an unclosed delimiter. Closed inline_sets_a_box explicitly
   and let inline_text take the trailing brace. Verified `cargo check` reports
   0 errors and all three of inline_sets_a_box / inline_text / plain_inline_text
   are present exactly once.

Generated artifacts (supported-latex.json x2, coverage.md, docs/user/compiler.md)
regenerated with render_supported_latex.sh from the resolved source rather than
taking either side, since neither side's counts are correct after the merge.
apps/mac sync --check passes.

Commit-Executor: daniel-parent
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant