Skip to content

compiler: hyperref options, autoref/nameref, link/destination/bookmark records (35/132) - #131

Closed
GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/hyperref-coverage
Closed

GoKubar wants to merge 2 commits into
mainfrom
agent/kabir-claude/hyperref-coverage

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

What

hyperref in the compiler (product path, outside the macro-expansion pass): options, commands, and typed link / destination / bookmark records for PDF export. Overlap check: no active lane (FT-037 daniel-links is an unmerged, unwired model crate on a paused machine; no open hyperref/link/outline PR).

  • crate::hyperref (new): \usepackage[..]{hyperref} + \hypersetup keyval options (colorlinks, hidelinks, draft, pdfborder, link/cite/url/file colours and border colours, bookmarks, bookmarksnumbered/open/depth, pdftitle/author/subject/keywords/creator/producer, pagemode/startview; known inert keys accepted, unknown keys warned). Colours follow color.sty (8 names) or, when xcolor is loaded, xcolor names and c!p!c mixes in the first colour's model. English autoref name table (hyperref.sty 8302-8318), \HyRef@testreftype lookup, UTF-16BE PDF strings.
  • Parsed::hyperref: links (source span of the visible text, class link/url/cite/file, target = named destination | label | URI), anchors (named destinations: section.1, subsection.2.1, section*.N, equation.N, figure.N, table.N, Item.N, theorem.N, cite.key, name.level, hypertargets), bookmarks (level-checked as in hpdftex.def, depth-filtered, numbered on request, \texorpdfstring pdf argument).
  • Commands: \autoref, \autopageref, \nameref, \hyperref[label]{text} and the 4-argument form, \hyperlink, \hypertarget, \hyperdef, \phantomsection, \texorpdfstring, \pdfbookmark, \hypersetup, \pdfstringdefDisableCommands/\hyperbaseurl/\setpdflinkmargin (accepted), starred \ref*/\pageref*/\autoref*/\nameref*, 19 \...autorefname names (renewable), NoHyper environment. \url/\href/\cite/\ref record links; \href{#name} is internal.
  • Link text arguments are re-queued as ordinary braced groups, so math/nested commands inside \hyperlink{x}{...} work and keep exact spans.
  • Kernel fixes found by the oracle: table + \caption (Table n); enumerate \label values (1, 1a, 1(a)i) with the list restoring \@currentlabel at \end.
  • Inline::Label gains anchor/title; Inline::Reference gains form (Number/Auto/Name) and linked. Existing consumers that match with .. are unaffected.

Oracle (MacTeX pdflatex 1.40.29 + hyperref 7.01p, oracle only)

32 cases in crates/compiler/tests/hyperref_oracle/cases, expected data extracted by scripts/hyperref_oracle.py (uncompressed pdflatex output: annotations, name tree, outlines, Info, catalog, words, fill ops). tests/hyperref_oracle.rs (no TeX) compares exactly: destination names, link target sequence, /Border, /C, single-line link text, outline titles/depth/destinations//Count, Info, /PageMode, /OpenAction, colorlinks fill operators. 32/32 cases match. Word positions and link rectangles are recorded but not asserted: the compiler's own layout is not the pdfTeX-metric pipeline; they are for render-pipeline adoption.

Coverage

hyperref commands 2/132 (1.5%) -> 35/132 (26.5%); hyperref environments 0/2 -> 1/2; kernel environments 15/30 -> 16/30; total 194/1003 -> 229/1003. Regenerated with scripts/render_supported_latex.sh.

Gates

cargo test --no-fail-fast in crates/compiler: every suite green (lib 241, hyperref_oracle 2, hw1_preamble, hw2_gate, corpus_gate, xref_toc, references_and_figures, supported_latex generated/arms/inventory ...) except two failures that reproduce identically on an untouched git archive origin/main export: robustness::deeply_nested_input_does_not_blow_the_stack (2000 nested \frac stack overflow in math parsing) and supported_latex::canonical_names_outside_the_inventory_are_diagnosed (debug_assert in P::unsupported). HW1/HW2 do not load hyperref. clippy: no warnings in touched code.

Follow-ups / re-pin

  • apps/mac/Sources/FlashTeXMac/Resources/supported-latex.json must be re-synced (apps/mac/scripts/sync-supported-latex.sh); the CI --check step fails until then (apps/ is outside this lane).
  • render-pipeline vendor/compiler re-pin: believed source-compatible (.. patterns), not built; until the adapter reads form, \autoref/\nameref print the number only in the pipeline. Link painting/annotations need the stacked crates/pdf PR and a display-list-v2 link proposal.

Dependencies (Commander rule: every PR against main)

GoKubar and others added 2 commits September 13, 2026 07:17
…mark records

hyperref in the product path: \usepackage[..]{hyperref} and \hypersetup
options, \autoref/\autopageref/\nameref, \hyperref, \hyperlink,
\hypertarget, \hyperdef, \phantomsection, \texorpdfstring, \pdfbookmark,
starred references, the autoref name table and NoHyper. Parsed::hyperref
records links (span, class, target), named destinations and bookmarks for
PDF export. table captions and enumerate \label values follow article.cls.

32 pdflatex oracle cases (expected data + generator, no TeX in cargo test)
match on destinations, link targets, /Border, /C, link text, outlines,
Info and colorlinks colours. hyperref coverage 2/132 -> 35/132.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude hyperref coverage, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
Resolved parser.rs (P initialiser: hyperref fields + column_types;
package_matches_layout: hyperref + array arms) and regenerated the
supported-LaTeX artefacts. Fixed the links proposal path in the oracle
test docs.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude hyperref coverage, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
Semantic overlap with #153 resolved to one counter model: equation/figure/table step through xref::Counters (#155); Counters::report() registers them within chapter (#153's numbering), so \chapter's step resets them, and #153's hand-kept equation/figure/table counters and within_chapter are removed. Kept #131's caption/equation hyperref anchors and label_inline. Conflicts: HOST_PRELUDE (amsthm defaults + \counterwithin/\counterwithout pass-through), parser.rs fields/dispatch/captions/bibliography OpenList + subequations begin/end/equation/multirow/labels, supported.rs (counter commands + main's hyperref url/href). Also: Counters::set_within rewritten on #155's Vec reset_by/pieces; #149's \numberwithin arm and fn removed (shadowed #155's counter_numbering with [style]); #155's theorem-counter special case removed (theorem counters are Counters entries since #149); TEXT_EXTRA_ARMS drops numberwithin (now in BUILT_INS); unused HashMap import in parser/boxes.rs.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…ession handoff)

Stage 1 partly done: #131, #137, #153 (incl. #142), #144, #147, #149, #150,
#155, #159, #163, #164 merged with conflicts and post-expansion fixes recorded
in docs/evidence/integration-2026-09-13b/merge-log.md. Remaining: #166, #169,
#148, #161, then the inventory regeneration and stages 2-4. The helper scripts
under tools/ hard-code the original worktree path.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
Conflicts: bib.rs BibItem accessor; parser.rs Parsed fields/initialisers,
preamble dispatch and \usepackage (two braces git had shared were restored),
\bibliographystyle vs main's now-dead inline \cite body, and the \bibitem
label. Re-added #131's hyperref cite.<key> links inside citation() and #147's
pending_item template for bibliography markers.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar added a commit that referenced this pull request Sep 13, 2026
…merges

Every stage 1 merge took main's side of the generated inventory and deferred
the regeneration to the end of the stage. Running
crates/compiler/scripts/render_supported_latex.sh picks up #131, #137, #144,
#147, #149, #150, #153, #155, #159, #163, #164, #166 and #169, so
supported_latex::generated_artifacts_are_current passes again.

The TeX Live-derived canonical denominator is deliberately untouched: this
machine has TeX Live 2025, not the MacTeX the committed file was pinned from.

Implementation-Agent: Claude Opus 5 (subagent kabir-claude integration, nixos-pc-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu
GoKubar pushed a commit that referenced this pull request Sep 14, 2026
Decode the proposal §3 navigation object (tolerant of absence) on both
v2 readers, request the capability only with display-list-v2 (setLiveV2
and configure_layout), and hit-test link rects in a pure type. Clicks
open http/https/mailto via NSWorkspace and scroll internal destinations;
file: and javascript: are rejected.

Control on unmodified c02fcb9: Selected tests 22 executed, 5 skipped,
0 failures (PreviewV2Tests 8/0, DisplayListDeltaTests 5 executed 4 skipped,
V2ImageTests 9 executed 1 skipped). DisplayListCompact tests are not on
this main.

After: DisplayListLinksTests 9 executed 0 failures; existing suites still
green (PreviewV2Tests 8/0, PreviewV2LiveTests 7/0, DisplayListDeltaTests
5/4 skipped, V2ImageTests 9/1 skipped). RenderingV2Tests 14/0.
swift build: Build complete! (0.36s)

Next: pipeline producer (issue step 2) after #131; no outline sidebar.

Implementation-Agent: cursor-agent cursor-grok-4.6-high-fast
Commit-Executor: cursor-agent
Lane-Owner: daniel-parent (mac-m5pro-dq222)

Co-authored-by: Cursor <[email protected]>
d-q222 added a commit that referenced this pull request Sep 14, 2026
…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
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

GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Closing as abandoned (per backlog triage). 77 files / +10,799 on a 2026-09-13 base; conflicting with current main and untouched since. Nothing from it landed: main still lists autoref/nameref/hyperref as known-unimplemented (crates/compiler/src/vocabulary.rs:67,293), and no open PR depends on this branch. The 35/132 hyperref coverage here is real work worth mining when a hyperref lane restarts, but it needs a full rebuild on current main, not a rebase — the parser and xref architecture have both moved. Branch agent/kabir-claude/hyperref-coverage is preserved.

@GoKubar GoKubar closed this Sep 15, 2026
@GoKubar
GoKubar deleted the agent/kabir-claude/hyperref-coverage branch September 16, 2026 04:18
d-q222 added a commit that referenced this pull request Sep 16, 2026
What changed:
- `pdf::write_pdf_exact` calls `flashtex_pdf::exact::render_exact_with` with
  a `navigation::Navigation` built from the display list's own `navigation`,
  instead of the navigation-free `render_exact`. `/Annots` now carry one
  `/Link` per rectangle with a `/URI` action.
- The rectangle is flipped per page: the display list is y down from the
  page's top-left in ticks, a `/Rect` is `[llx lly urx ury]` y up from the
  bottom-left in points. Ticks are 2^-20 of a point, so `Decimal::from_ratio`
  is exact and never rounds.
- No vendor edit: `navigation::Navigation` and `render_exact_with` already
  exist in the pinned `vendor/pdf` (#132), and `from_v2` is untouched — the
  navigation is read off the `DisplayList` the exporter already has.

`/Border [0 0 0]` and no `/C`. pdflatex under plain hyperref draws a coloured
box, but under `colorlinks` or `hidelinks` it draws nothing and colours the
text, and the pinned compiler does not expose which options the document set.
Drawing nothing is the choice that cannot add ink the author did not ask for,
and it is consistent with the page content, which carries no link colouring.

What was run:
- cargo test -p flashtex-render-pipeline --test links_pdf_annotations
  test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
- cargo test -p flashtex-render-pipeline --lib --test links_navigation --test page_window --test cli_e2e
  test result: ok. 169 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
  test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
  test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
- PyMuPDF on the exported PDF against pdflatex's, same source:
  pdflatex https://example.com Rect(165.427001953125, 126.8499755859375, 266.7959899902344, 137.9749755859375)
  ours     https://example.com Rect(165.42747497558594, 126.84979248046875, 266.7972717285156, 137.974853515625)
  pdflatex https://ex.org/a    Rect(287.49700927734375, 126.8499755859375, 330.4739990234375, 137.9749755859375)
  ours     https://ex.org/a    Rect(287.4972839355469, 126.84979248046875, 330.4753723144531, 137.974853515625)
  max delta 0.0014 bp.

Next step: internal destinations, the outline and hyperref's option state
(`border`/`color`, `page_mode`, `info`) still need #131's compiler records and
a vendor re-pin.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
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