Skip to content

compiler: cleveref — \cref, \Cref, ranges, \cpageref, \labelcref and \crefname, following cleveref.sty - #434

Closed
d-q222 wants to merge 7 commits into
mainfrom
agent/daniel-parent/cleveref
Closed

d-q222 wants to merge 7 commits into
mainfrom
agent/daniel-parent/cleveref

Conversation

@d-q222

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

Copy link
Copy Markdown
Contributor

daniel-parent (Codex luna-max lane GH-CLEVEREF, reviewed by daniel-parent plus two independent read-only Codex reviews checked against TeX Live 2026's cleveref.sty and pdflatex). The compiler listed \cref/\Cref as unimplemented.

What changes

  • Commands: \cref, \Cref, \crefrange, \Crefrange, \cpageref, \Cpageref, \labelcref, \crefname and \Crefname, gated on \usepackage{cleveref}, with its [capitalise] and [noabbrev] options.
  • Label types:
    • The type is taken from the counter that set the label: section, equation (including align rows), figure, enumerate item and theorem environments.
    • subsection/subsubsection fall back to the section name, as in cleveref, unless a \crefname{subsection} override exists.
  • Output follows cleveref's English defaults:
    • Within a type there's no Oxford comma: sections 1, 2 and 4.
    • Between groups: section 1, eq. (1), and fig. 1.
    • Consecutive values compress into ranges (sections 1 to 3), including \cpageref and \labelcref.
    • [capitalise] keeps abbreviations: \cref gives Eq. (1), \Cref gives Equation (1).
  • Names:
    • \crefname never overwrites an existing capitalised name: after \crefname{section}{sec}{secs}, \Cref still gives Section.
    • A capitalised form is derived only for types that have none.
  • Existing \ref fixed along the way: enumerate labels now store counter values, not display strings.
    • An item \ref is 1 (it used to be 1.).
    • Nested items follow article.cls \p@enumii: 1a at level 2 and 1(a)i at level 3.
  • Inventory: regenerated, and both supported-latex.json copies are byte-identical.

Review rounds

  1. First review found:

    • an Oxford comma within a type;
    • and-joined groups;
    • capitalise implying noabbrev;
    • mixed-kind ranges refused;
    • no \cpageref/\labelcref compression;
    • \crefname derivation clobbering names;
    • subsection names;
    • the 1. enumerate \ref regression.

    All fixed. \autoref was dropped from this lane, since compiler: hyperref options, autoref/nameref, link/destination/bookmark records (35/132) #131 owns it; it keeps its old "unsupported" diagnostic.

  2. Re-review confirmed those and found three remaining issues, all fixed with failing tests first:

    • nested enumerate \ref lost the parent counter;
    • default \Crefname precedence;
    • an explicit subsection override was ignored.

    Two of its suggestions were declined on evidence:

    • theorem names: pdflatex prints ?? 1 for \newtheorem{foo}{Lemma} without a \crefname;
    • \cref* link suppression: the compiler has no link backend.

Tests

On this branch after merging main (345bc7d5):

  • test result: ok. 327 passed; 0 failed; 0 ignored (compiler lib)
  • test result: ok. 11 passed; 0 failed (cleveref), ok. 10 passed (references_and_figures), ok. 8 passed (supported_latex)
  • All other compiler targets are ok.
  • render-pipeline/tests/cleveref.rs is #[ignore] until the next vendor/compiler re-pin brings CleverReference to the pipeline.

Overlap check

Not done

  • \cref* hyperlink suppression.
  • Table captions: the compiler's figure-only caption limit.
  • \appendix.
  • \crefname in the body applied in document order.
  • Letter/roman enumerate range compression.

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

What changed: added three compiler regression tests covering section range compression, equation naming, custom names, and undefined-reference diagnostics.
What ran: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/compiler/Cargo.toml --test cleveref -- --nocapture; 0 passed, 3 failed.
Next step: implement compiler cleveref parsing, label kinds, naming, and layout resolution.
Open questions: pipeline vendor remains pinned before the new compiler node.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)
What changed: added compiler parsing, counter-kind label metadata, cleveref naming/options, two-pass rendering, undefined diagnostics, and focused tests for named references and autoref.

What was run: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo check --manifest-path crates/compiler/Cargo.toml — passed with four pre-existing unreachable-pattern warnings in math-layout. CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/compiler/Cargo.toml --test cleveref -- --nocapture — test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s.

Next step: regenerate compiler and Mac supported-LaTeX inventories, then add the pinned render-pipeline ignored test.

Open questions: render-pipeline cannot consume the new Inline node until its frozen vendor compiler is re-pinned.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)
What changed: regenerated the compiler supported-LaTeX JSON, coverage, documentation section, and synchronized the Mac resource JSON with the new cleveref package and commands.

What was run: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref crates/compiler/scripts/render_supported_latex.sh — regenerated successfully. CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/compiler/Cargo.toml --test supported_latex -- --nocapture — test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.03s. apps/mac/scripts/sync-supported-latex.sh --check --root /Users/dqi26/flashtex-wt/cleveref — bundled copy is current.

Next step: add the render-pipeline regression as ignored until the frozen vendor compiler is re-pinned.

Open questions: pipeline rendering cannot use the compiler Inline::CleverReference node at vendor commit e44d591.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)
What changed: added a render-pipeline regression for Section and equation cleveref text, explicitly ignored while the vendored compiler remains at e44d591.

What was run: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/render-pipeline/Cargo.toml --test cleveref -- --nocapture — test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s.

Next step: run final compiler and pipeline scoped checks, then hand off the three local checkpoint SHAs to daniel-parent.

Open questions: a future vendor re-pin must add adapter/layout handling for Inline::CleverReference before removing the ignore.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)
…ns and names

What changed:
- \autoref removed entirely (PR #131 owns it); vocabulary keeps it unimplemented.
- Enumerate \ref stores the counter value, not the "1." display label.
- Conjunctions follow cleveref's English defaults (no Oxford comma within a type; group conjunctions from cleveref.sty).
- [capitalise] keeps abbreviations.
- \crefname does not overwrite an existing \Crefname.
- subsection/subsubsection alias to section.
- \crefrange accepts mixed raw kinds of one cleveref type.
- \cpageref and \labelcref compress ranges.
- cref/Cref leave KNOWN_UNIMPLEMENTED_COMMANDS; both inventories regenerated, byte-identical.

Checked against TeX Live 2026 cleveref.sty and pdflatex. \newtheorem{foo}{Lemma} prints "?? 1" in pdflatex (cref format undefined), so theorem names are unchanged.

What was run (Codex, worktree-local target dir):
- Compiler lib: test result: ok. 327 passed; 0 failed
- cleveref: test result: ok. 10 passed; 0 failed
- references_and_figures: test result: ok. 8 passed; 0 failed
- supported_latex inventory: test result: ok. 8 passed; 0 failed
- Pipeline cleveref: 0 passed; 1 ignored (until the vendor re-pin)

Not done: \cref* link suppression (no compiler link backend), table captions, \appendix, document-order body \crefname.

Implementation-Agent: codex gpt-5.6-luna (max), session 01a0a0c4-9497-7281-bf35-3b985b2ec504
Commit-Executor: daniel-parent (the resumed Codex session cannot write .git)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…e, subsection overrides

Fixes three defects from the independent re-review. Each has a test that failed first.
- A nested enumerate \ref stores article.cls values \p@enumii\theenumii = 1a,
  and 1(a)i at level 3. Display labels are unchanged.
- The built-in capitalised cleveref names are seeded, so \crefname{section}{sec}{secs}
  followed by \Cref gives "Section", not "Sec". The new test has no \Crefname call.
- An explicit \crefname{subsection} override is checked before the section alias.
  Alias grouping and ranges still hold.

What was run (Codex):
test result: ok. 327 passed; 0 failed; 0 ignored  (compiler lib)
test result: ok. 11 passed; 0 failed               (cleveref)
test result: ok. 10 passed; 0 failed               (references_and_figures)
test result: ok. 8 passed; 0 failed                (supported_latex)
All other compiler targets passed.

Not done:
- theorem names: pdflatex prints ?? for \newtheorem{foo}{Lemma};
- \cref* link suppression: there is no compiler link backend;
- letter/roman enumerate range compression.

Implementation-Agent: codex gpt-5.6-luna (max), session 01a0a0c4-9497-7281-bf35-3b985b2ec504
Commit-Executor: daniel-parent (the resumed Codex session cannot write .git)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Superseded by #460, which is this branch rebased onto current main.

The only conflict was docs/user/compiler.md, a generated artefact. Per the integration rules it was not hand-merged: it was regenerated from the merged source with crates/compiler/scripts/render_supported_latex.sh then apps/mac/scripts/sync-supported-latex.sh, so it carries both this PR's cleveref entries and main's newer inventory (e.g. \capitalcaron from #416). No source file conflicted — the implementation in #460 is yours, unchanged.

Gates verified green on the rebased branch before opening #460: compiler 630/0, render-pipeline 304/0, bridge 170/0, flashtex-cli 35/0; amsmath 59/59; tabular 106/106; real-world corpus page counts 22/22; HW1 and HW2 3 pages / 0 errors; sync-supported-latex.sh --check current; zero font FAILURE diagnostics.

Closing this one in favour of #460. Branch agent/daniel-parent/cleveref is left intact.

Implementation-Agent: Claude Opus 5 (lane linux-integration-2, linux-primary)

@GoKubar GoKubar closed this Sep 14, 2026
GoKubar added a commit that referenced this pull request Sep 14, 2026
…\crefname (rebase of #434) (#460)

* wip(#GH-CLEVEREF): add failing cleveref regressions

What changed: added three compiler regression tests covering section range compression, equation naming, custom names, and undefined-reference diagnostics.
What ran: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/compiler/Cargo.toml --test cleveref -- --nocapture; 0 passed, 3 failed.
Next step: implement compiler cleveref parsing, label kinds, naming, and layout resolution.
Open questions: pipeline vendor remains pinned before the new compiler node.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* wip(#GH-CLEVEREF): implement compiler cleveref references

What changed: added compiler parsing, counter-kind label metadata, cleveref naming/options, two-pass rendering, undefined diagnostics, and focused tests for named references and autoref.

What was run: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo check --manifest-path crates/compiler/Cargo.toml — passed with four pre-existing unreachable-pattern warnings in math-layout. CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/compiler/Cargo.toml --test cleveref -- --nocapture — test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s.

Next step: regenerate compiler and Mac supported-LaTeX inventories, then add the pinned render-pipeline ignored test.

Open questions: render-pipeline cannot consume the new Inline node until its frozen vendor compiler is re-pinned.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* wip(#GH-CLEVEREF): regenerate supported LaTeX inventories

What changed: regenerated the compiler supported-LaTeX JSON, coverage, documentation section, and synchronized the Mac resource JSON with the new cleveref package and commands.

What was run: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref crates/compiler/scripts/render_supported_latex.sh — regenerated successfully. CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/compiler/Cargo.toml --test supported_latex -- --nocapture — test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.03s. apps/mac/scripts/sync-supported-latex.sh --check --root /Users/dqi26/flashtex-wt/cleveref — bundled copy is current.

Next step: add the render-pipeline regression as ignored until the frozen vendor compiler is re-pinned.

Open questions: pipeline rendering cannot use the compiler Inline::CleverReference node at vendor commit e44d591.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* wip(#GH-CLEVEREF): guard pipeline coverage for vendor re-pin

What changed: added a render-pipeline regression for Section and equation cleveref text, explicitly ignored while the vendored compiler remains at e44d591.

What was run: CARGO_TARGET_DIR=/Users/dqi26/flashtex/target-cleveref cargo test --manifest-path crates/render-pipeline/Cargo.toml --test cleveref -- --nocapture — test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s.

Next step: run final compiler and pipeline scoped checks, then hand off the three local checkpoint SHAs to daniel-parent.

Open questions: a future vendor re-pin must add adapter/layout handling for Inline::CleverReference before removing the ignore.

Implementation-Agent: Codex GPT-5
Commit-Executor: Codex
Lane-Owner: daniel-parent (mac-m5pro-dq222)

* wip(#GH-CLEVEREF): review fix-up — drop \autoref, cleveref conjunctions and names

What changed:
- \autoref removed entirely (PR #131 owns it); vocabulary keeps it unimplemented.
- Enumerate \ref stores the counter value, not the "1." display label.
- Conjunctions follow cleveref's English defaults (no Oxford comma within a type; group conjunctions from cleveref.sty).
- [capitalise] keeps abbreviations.
- \crefname does not overwrite an existing \Crefname.
- subsection/subsubsection alias to section.
- \crefrange accepts mixed raw kinds of one cleveref type.
- \cpageref and \labelcref compress ranges.
- cref/Cref leave KNOWN_UNIMPLEMENTED_COMMANDS; both inventories regenerated, byte-identical.

Checked against TeX Live 2026 cleveref.sty and pdflatex. \newtheorem{foo}{Lemma} prints "?? 1" in pdflatex (cref format undefined), so theorem names are unchanged.

What was run (Codex, worktree-local target dir):
- Compiler lib: test result: ok. 327 passed; 0 failed
- cleveref: test result: ok. 10 passed; 0 failed
- references_and_figures: test result: ok. 8 passed; 0 failed
- supported_latex inventory: test result: ok. 8 passed; 0 failed
- Pipeline cleveref: 0 passed; 1 ignored (until the vendor re-pin)

Not done: \cref* link suppression (no compiler link backend), table captions, \appendix, document-order body \crefname.

Implementation-Agent: codex gpt-5.6-luna (max), session 01a0a0c4-9497-7281-bf35-3b985b2ec504
Commit-Executor: daniel-parent (the resumed Codex session cannot write .git)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

* wip(#GH-CLEVEREF): nested enumerate \ref, default \Crefname precedence, subsection overrides

Fixes three defects from the independent re-review. Each has a test that failed first.
- A nested enumerate \ref stores article.cls values \p@enumii\theenumii = 1a,
  and 1(a)i at level 3. Display labels are unchanged.
- The built-in capitalised cleveref names are seeded, so \crefname{section}{sec}{secs}
  followed by \Cref gives "Section", not "Sec". The new test has no \Crefname call.
- An explicit \crefname{subsection} override is checked before the section alias.
  Alias grouping and ranges still hold.

What was run (Codex):
test result: ok. 327 passed; 0 failed; 0 ignored  (compiler lib)
test result: ok. 11 passed; 0 failed               (cleveref)
test result: ok. 10 passed; 0 failed               (references_and_figures)
test result: ok. 8 passed; 0 failed                (supported_latex)
All other compiler targets passed.

Not done:
- theorem names: pdflatex prints ?? for \newtheorem{foo}{Lemma};
- \cref* link suppression: there is no compiler link backend;
- letter/roman enumerate range compression.

Implementation-Agent: codex gpt-5.6-luna (max), session 01a0a0c4-9497-7281-bf35-3b985b2ec504
Commit-Executor: daniel-parent (the resumed Codex session cannot write .git)
Lane-Owner: daniel-parent (mac-m5pro-dq222)
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

---------

Co-authored-by: d-q222 <[email protected]>
GoKubar added a commit that referenced this pull request Sep 14, 2026
…nders it (#465)

#460 (cleveref, the rebase of #434) added \cref to the compiler inventory, which
turned the Mac drift guard red on main:

    CompletionTests.swift:476: error:
      -[FlashTeXMacTests.CompletionTests testCommandDocsNameOnlyKnownCommands]:
      XCTAssertFalse failed - \cref is rendered by the compiler now;
      remove it from beyondCompiler

That guard is doing exactly its job. `beyondCompiler` documents standard LaTeX
the editor explains even though the compiler only diagnoses it, and its own
comment states the contract: "a name listed here must leave the list once the
compiler renders it." So this drops "cref" from the set. `Docs.table["cref"]`
stays — the hover text is still wanted, it is now backed by the inventory
instead of by the beyond-compiler list.

`\cref` was the only name affected: the full suite reported one failure, and the
other cleveref spellings (\Cref, \crefrange, \cpageref, \labelcref, \crefname)
were never in `beyondCompiler`.

The ubuntu CI jobs compile none of this, so the breakage was invisible to
#460's checks; it was caught by running the Mac suite against merged main.

Verified on the Mac (apps/mac, fresh /tmp worktree and build directory, this
change merged onto main @ 620aac8):
    swift build                                                    ok
    swift test --skip NearbyInterfaceTests --skip NearbyLANInterfaceTests
      before this change: 1210 tests, 137 skipped, 1 failure
      after  this change: 1210 tests, 137 skipped, 0 failures

Implementation-Agent: Claude Opus 5 (lane linux-integration-2, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
@GoKubar
GoKubar deleted the agent/daniel-parent/cleveref branch September 16, 2026 04:18
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.

2 participants