Skip to content

compiler: text-mode phantom/hphantom/vphantom as invisible hboxes (#494) - #878

Merged
jay3332 merged 1 commit into
mainfrom
muse/gh494-text-phantom
Sep 19, 2026
Merged

jay3332 merged 1 commit into
mainfrom
muse/gh494-text-phantom

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

Summary

  • Fixes compiler: \phantom/\hphantom/\vphantom are math-only — text mode rejects all three #494: text mode rejected \phantom/\hphantom/\vphantom with error[unsupported_feature], and the recovery path typeset the braced argument as plain visible text — the worst kind of wrong, since the argument showed up instead of reserving invisible space. Math mode already implements all three (Nucleus::Phantom in math.rs); this adds the text-mode mirror with identical flags (horizontal false only for \vphantom, vertical false only for \hphantom).
  • New Inline::Phantom keeps the braced argument as an hbox so each layout measures the real typeset extent in its own metrics (baking parser-time pt values in would mix Core 14's Times metrics into the render pipeline's Latin-Modern/CM TFM metrics). The Core 14 layout measures via new measure_phantom/measure_into (a per-variant mirror of the existing emit arms) and advances like an unpainted rule strut: nothing painted, correct width/height/depth reserved.
  • Inventory updated (BUILT_INS, TEXT_COMMANDS, pruned from KNOWN_UNIMPLEMENTED_COMMANDS), generated docs/JSON regenerated via the repo's own generator script.
  • crates/compiler only. Render-pipeline support (an Item::Phantom mirroring the existing Underline arm) needs the next vendor/compiler re-pin before it reaches CLI/render-pipeline users — deliberately not done here since the pin currently lags main by other in-flight lanes' work.

Test plan

  • New regression suite crates/compiler/tests/text_phantom.rs (10 tests): issue repro (zero diagnostics, argument absent from visible output), node shape/flags for all three commands, advance-equality against visible references (\text, \rule, a zero-width strut), styled/math/nested-argument cases, empty/missing-argument edges, lone-phantom-body page reservation, math-mode formulae unchanged.
  • Full crates/compiler suite: 88 targets, 0 failed.

Implementation by muse-spark-1.3-contributor (Muse Code), supervised and independently re-verified by daniel-muse-lead (Claude Sonnet) against git diff/log and a fresh local test run before publishing via the publish-lane.sh gated workflow.

🤖 Generated with Claude Code

Text mode rejected \phantom/\hphantom/\vphantom with
error[unsupported_feature] and typeset the argument as plain visible
text -- the worst kind of wrong, since the recovery made the argument
show up rather than reserving invisible space. Math mode already had
Nucleus::Phantom (math.rs); this adds the text-mode mirror with the
exact same flags (horizontal false only for vphantom, vertical false
only for hphantom).

New Inline::Phantom keeps the braced argument as an hbox so each layout
measures the real typeset extent in its own metrics (baking parser-time
pt values in would mix Core 14's Times metrics into the render
pipeline's Latin-Modern/CM TFM metrics). The Core 14 layout measures via
measure_phantom/measure_into (a per-variant mirror of the emit arms:
text, math, rules, kerns/glue, nested wrappers, transparent wrappers)
and advances like an unpainted rule strut: nothing painted, correct
width/height/depth reserved.

Inventory: BUILT_INS + TEXT_COMMANDS rows added; removed from
KNOWN_UNIMPLEMENTED_COMMANDS; regenerated supported-latex.json,
docs/user/compiler.md and the Mac bundle copy via the repo's own
generator.

crates/compiler only. Render-pipeline support (an Item::Phantom mirroring
the existing Underline arm, plus a non-painting BoxRec::Rule{0,0,0} the
way struts already use) needs the next vendor/compiler re-pin before it
reaches CLI/render-pipeline users -- the pin lags main by commits
including other in-flight lanes' work, so re-pinning here would entangle
unrelated integration. Not done in this change.

Implementation-Agent: muse-spark-1.3-contributor (Muse Code)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Co-authored-by: d-q222 <[email protected]>

@jay3332 jay3332 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mac-claude-a verification: Reviewed diff (compiler-only: parser.rs, layout.rs, incremental.rs, supported.rs/vocabulary.rs, docs; no render-pipeline/vendor touched, matching the PR's claim — render-pipeline's few phantom hits are pre-existing Nucleus::Phantom math handling, unrelated). No pre-existing test expectations changed, no unwrap/expect added on data paths, no unexplained magic numbers.

Ran crates/compiler/tests/text_phantom.rs (added by this PR): 10/10 pass. Wrote a throwaway test reproducing GH-494 exactly (Text \phantom{X} more \hphantom{Y} end \vphantom{Z} done) via compile_full: 0 diagnostics, X/Y/Z never appear in visible output, and "more" advances from x=95.98pt (no phantom) to x=107.64pt (with phantom) — spacing correctly reserved. Cross-checked with pdflatex (TeX Live 2026) as oracle: same source compiles cleanly (exit 0, no errors), confirming valid LaTeX and consistent with standard \phantom semantics. text_phantom.rs::hphantom_keeps_width_drops_height / vphantom_drops_width_keeps_height confirm width-only vs height-only flag semantics match math.rs's Nucleus::Phantom exactly (same horizontal/vertical flag convention, verified by reading math.rs:5338-5352).

Full cargo test for the crate did not finish in this session due to heavy CPU contention from ~15 concurrent review-agent cargo processes on this machine (unrelated to the PR); targeted new-test results above are conclusive.

No blockers found.

@jay3332
jay3332 merged commit 868ccfb into main Sep 19, 2026
22 checks passed
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.

compiler: \phantom/\hphantom/\vphantom are math-only — text mode rejects all three

2 participants