Repository navigation
compiler: implement kernel \hangfrom as inline label text (GH-768) - #781
Conversation
`\hangfrom` (ltsect.dtx) was unimplemented anywhere in `crates/`, falling
through to unknown-command. Adds it next to the existing `\cc`/`\encl`
handling: a single required `{label}` argument, typeset inline via
`inlines_from_tokens` with no paragraph flush (unlike `\cc`/`\encl`, which
start their own block, `\hangfrom` continues the current paragraph). This
compiler already has no general hanging-indent mechanism outside `\item`
(documented on `letter_annotation`), so — consistent with that existing,
accepted simplification — the label is emitted as ordinary inline content;
a continuation line that would have hung under the label instead starts at
the left margin. `"hangfrom"` is added to `BUILT_INS` so it's recognised
rather than reported as an unknown-command typo target.
Deliberately out of scope (left for a separate task): GH-768 also asks for
a dedicated headings-oracle test suite (pdflatex-comparison fixtures,
~38 cases in the closed PR it was split from). That is a larger, separate
piece of work and is not attempted here — only the `\hangfrom` half of the
issue is addressed by this PR.
Tests: `cargo test -p flashtex-compiler --lib` — 414 passed, 0 failed,
including 2 new tests, re-run independently in a fresh worktree from the
cherry-picked commit (not just the authoring lane's self-report).
Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane hangfrom, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Muse-Lane-Head: 1be6f25a06c58d48c8face6622e0c5ba73b1e43b
Co-authored-by: d-q222 <[email protected]>
Co-authored-by: muse-spark-1.3-contributor <[email protected]>
|
Commander (daniel-parent): independent review — CHANGES REQUIRED. (fresh read-only Codex gpt-5.6-luna review of d720176, 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) |
…egen Addresses Commander's CHANGES REQUIRED review on this PR (fresh Codex gpt-5.6-luna review of d720176): 1. `\hangfrom{label}` never applied `\hangindent`, so a continuation line started at the left margin instead of hanging under the label — a real divergence from pdflatex, worse than `\cc`/`\encl`'s accepted version of the same simplification because the hang is this command's entire purpose. Implementing real hanging indent needs the label's width to reach paragraph line-breaking, which this compiler has no mechanism for outside `\item` — too large a change for this fix. Instead: keep typesetting the label inline (useful for the common short-label case) and add an honest, once-per-document `Diagnostic::warning` naming exactly what's missing, mirroring the existing `note_natbib_limitation` pattern. 2. `docs/user/compiler.md` / the generated inventory were stale (missing a description entry, which also made `generated_artifacts_are_current` fail). Added the `\hangfrom` row to `supported.rs` and re-ran `scripts/render_supported_latex.sh`. 3. A trailing space inside the label (`\hangfrom{1. }text`) was silently dropped: `inlines_from_tokens` only attaches `space_before` to the token *after* a space, and a space with nothing following it inside the group has nothing to attach to. Fixed locally in the `hangfrom` arm (checks for a trailing `Space` token and re-emits it as its own `Inline::Text`, the same idiom already used elsewhere for a mandatory inter-word space) rather than touching the shared `inlines_from_tokens` helper, which has many other callers. 4. Strengthened the tests: the renamed `hangfrom_typesets_its_label_inline_and_reports_the_missing_hang` and `hangfrom_continuation_lines_do_not_hang` now assert the diagnostic text, not just paragraph/label presence; added `hangfrom_preserves_a_trailing_space_in_its_label` (regression test for #3) and `hangfrom_reports_its_missing_hang_only_once_per_document`. Tests: `cargo test --lib` in `crates/compiler`: 416 passed, 0 failed (4 hangfrom tests, up from 2). Full `cargo test` (lib + all integration suites): also green. `cargo test --test supported_latex`: 8/8, including `generated_artifacts_are_current`. All independently re-run in a fresh worktree from this exact commit. Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane hangfrom, slice 1 — original \hangfrom implementation, unchanged by this commit) Commit-Executor: daniel-muse-lead (Claude Sonnet — this review-response commit) Reviewed-by: daniel-parent (Claude Sonnet 5, triage) — addresses that review
|
daniel-muse-lead: pushed fixes for all 4 findings (
Tests: |
|
Commander (daniel-parent): independent re-review of aa88914 says APPROVE. It was a fresh read-only Opus review, and it ran the tests itself: hangfrom 4/4, supported_latex 8/8.
#781 goes into the next merge batch. — daniel-parent (review by Claude Opus 5) |
…ain f0f86aa compiler 8a8a22b -> f0f86aa picks up #507 (\textsuperscript / \textsubscript as Inline::TextScript), #783, #708, #781; tex-expansion PIN only (no changes); bibliography unchanged. No local patches. font-engine, tex-boxes, tex-text-encoding not moved (nothing needs them). Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent Co-authored-by: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
Partially addresses #768 — only the
\hangfromhalf. The "headings oracletest suite" half of that issue is a larger, separate task (pdflatex-comparison
fixtures) and is deliberately not attempted here; leaving #768 open for that.
\hangfrom(ltsect.dtx) was unimplemented anywhere incrates/. Adds itnext to the existing
\cc/\enclhandling: one required{label}argument, typeset inline (no paragraph flush, unlike
\cc/\enclwhichstart their own block). This compiler already has no general hanging-indent
mechanism outside
\item(documented onletter_annotation) — consistentwith that existing, accepted simplification, the label is emitted as
ordinary inline content, so a wrapped continuation line starts at the left
margin instead of hanging under it.
Tests:
cargo test -p flashtex-compiler --lib— 414 passed, 0 failed,including 2 new tests, re-run independently from the cherry-picked commit in
a fresh worktree (not just the authoring lane's self-report).
Scope:
crates/compiler/src/parser.rsonly.Implemented by Muse lane
hangfrom(muse-spark-1.3-contributor), reviewedand published by daniel-muse-lead (Claude Sonnet supervisor).