Skip to content

compiler: accept hyperref and \hypersetup, and break URLs the way url.sty does - #385

Closed
GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/hyperref-compiler-rebase
Closed

GoKubar wants to merge 1 commit into
mainfrom
agent/kabir-claude/hyperref-compiler-rebase

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Rebase of #379 onto main; #380 (natbib) landed in the same files and left it conflicting. Same commit, one conflict resolved by regenerating docs/user/compiler.md (259 -> 260 text-mode entries for \hypersetup, 15 -> 16 layout-neutral packages for hyperref).

Original PR body follows.


Four hyperref gaps, each pinned to a pdflatex (TeX Live 2025) measurement.

1. \hypersetup was a hard error. \hypersetup{colorlinks=true,...} in
the preamble produced \hypersetup is not supported in the document preamble on a valid document — fixtures/real-world/hyperref-toc line 7 is
exactly that call. It is now read and typesets nothing, in the preamble and
in the body.

2. \usepackage{hyperref} said "recognised but not implemented". That
wording claims the text may be wrong. It is not. Measured: the corpus
document compiled by pdflatex with and without hyperref (control = url.sty
plus a text-only \href) is 1062 words on 4 pages with 0 words moved,
and a second document exercising \maketitle, abstract,
\tableofcontents, \ref/\pageref, \url, \href, a \footnote and a
\cited bibliography gives 137 words, 1 page, 0 moved under every one of
default, colorlinks, hidelinks, pdfborder, bookmarks=false,
breaklinks, linktoc=all, pdfstartview, the pdf* metadata keys,
unicode and pdfpagemode.

So hyperref is accepted for those options. backref/pagebackref are
not: they add back-reference text to every bibliography entry, and they
would not compile in that harness, so they keep warning rather than being
claimed neutral on an unmeasured guess — as does any key not on the list,
which \hypersetup reports once.

What is genuinely missing — the PDF link annotations, destinations,
bookmarks and colorlinks colouring — keeps its own existing diagnostic.

3. The URL break set was wrong in both directions. Measured by setting
\url{xxxxxxxx<c>xxxxxxxx} in a 56pt minipage, a width at which the only
possible break is right after <c>:

  • breaks after / . ? & # = + : _ , ; ! | > ) ] ' @
  • does not break after - ~ * $

- and ~ used to break here and now do not, and the ten characters
: _ , ; ! | > ) ] ' @ were missing. The hyphen is the one that matters:
url.sty refuses to break there so a URL's own hyphen cannot be misread as
hyphenation.

4. A URL's hyphen carries a 0.5pt kern. \setbox0=\hbox{\url{a-b}} is
17.47511pt where \texttt{a-b} is 16.97511pt; \url{a-b-c} is 29.29185pt
against \texttt's 28.29185pt — exactly 0.5pt per hyphen and nothing for
any other character (\url{x.y} and \texttt{x.y} are both 16.97511pt).
Reading the glyph origins back out of the PDF puts the gap immediately after
the hyphen. push_url_text now emits that kern, which is also what stops
the pipeline's \exhyphenpenalty break from firing there: the hyphen ends
its run and a kern, not glue, follows it.

Suites: compiler 503 passed / 0 failed, against 498 / 0 on main (the
difference is this change's five new tests). Generated inventories
regenerated with crates/compiler/scripts/render_supported_latex.sh.

A vendor re-pin is needed for any of this to reach flashtex-render.
The pipeline builds against crates/render-pipeline/vendor/compiler
(Cargo.toml: flashtex-compiler = { path = "vendor/compiler" }), which is
byte-identical to crates/compiler today, so until it is re-pinned the
corpus still sees the old break set, no hyphen kern, and the \hypersetup
error. No vendor commit is made here.

pdflatex is an oracle only and is never in the product path.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

… url.sty does

Four hyperref gaps, each pinned to a pdflatex (TeX Live 2025) measurement.

**1. `\hypersetup` was a hard error.** `\hypersetup{colorlinks=true,...}` in
the preamble produced `\hypersetup is not supported in the document
preamble` on a valid document — `fixtures/real-world/hyperref-toc` line 7 is
exactly that call. It is now read and typesets nothing, in the preamble and
in the body.

**2. `\usepackage{hyperref}` said "recognised but not implemented".** That
wording claims the *text* may be wrong. It is not. Measured: the corpus
document compiled by pdflatex with and without hyperref (control = url.sty
plus a text-only `\href`) is **1062 words on 4 pages with 0 words moved**,
and a second document exercising `\maketitle`, `abstract`,
`\tableofcontents`, `\ref`/`\pageref`, `\url`, `\href`, a `\footnote` and a
`\cite`d bibliography gives 137 words, 1 page, 0 moved under every one of
`default`, `colorlinks`, `hidelinks`, `pdfborder`, `bookmarks=false`,
`breaklinks`, `linktoc=all`, `pdfstartview`, the `pdf*` metadata keys,
`unicode` and `pdfpagemode`.

So hyperref is accepted for those options. `backref`/`pagebackref` are
**not**: they add back-reference text to every bibliography entry, and they
would not compile in that harness, so they keep warning rather than being
claimed neutral on an unmeasured guess — as does any key not on the list,
which `\hypersetup` reports once.

What is genuinely missing — the PDF link annotations, destinations,
bookmarks and `colorlinks` colouring — keeps its own existing diagnostic.

**3. The URL break set was wrong in both directions.** Measured by setting
`\url{xxxxxxxx<c>xxxxxxxx}` in a 56pt `minipage`, a width at which the only
possible break is right after `<c>`:

- breaks after `/ . ? & # = + : _ , ; ! | > ) ] ' @`
- does **not** break after `- ~ * $`

`-` and `~` used to break here and now do not, and the ten characters
`: _ , ; ! | > ) ] ' @` were missing. The hyphen is the one that matters:
url.sty refuses to break there so a URL's own hyphen cannot be misread as
hyphenation.

**4. A URL's hyphen carries a 0.5pt kern.** `\setbox0=\hbox{\url{a-b}}` is
17.47511pt where `\texttt{a-b}` is 16.97511pt; `\url{a-b-c}` is 29.29185pt
against `\texttt`'s 28.29185pt — exactly 0.5pt per hyphen and nothing for
any other character (`\url{x.y}` and `\texttt{x.y}` are both 16.97511pt).
Reading the glyph origins back out of the PDF puts the gap immediately after
the hyphen. `push_url_text` now emits that kern, which is also what stops
the pipeline's `\exhyphenpenalty` break from firing there: the hyphen ends
its run and a kern, not glue, follows it.

Suites: compiler 503 passed / 0 failed, against 498 / 0 on main (the
difference is this change's five new tests). Generated inventories
regenerated with `crates/compiler/scripts/render_supported_latex.sh`.

**A vendor re-pin is needed for any of this to reach `flashtex-render`.**
The pipeline builds against `crates/render-pipeline/vendor/compiler`
(`Cargo.toml`: `flashtex-compiler = { path = "vendor/compiler" }`), which is
byte-identical to `crates/compiler` today, so until it is re-pinned the
corpus still sees the old break set, no hyphen kern, and the `\hypersetup`
error. No vendor commit is made here.

pdflatex is an oracle only and is never in the product path.

Implementation-Agent: Claude Opus 5 (lane nixos-hyperref, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

Rebased onto main after #380 (natbib) landed in the same files; the only
conflict was the generated command count in `docs/user/compiler.md`, resolved
by regenerating (`crates/compiler/scripts/render_supported_latex.sh`): 259 ->
260 text-mode entries (`\hypersetup`) and 15 -> 16 layout-neutral packages
(`hyperref`). `cargo test --release` on `crates/compiler` with the font
environment set: 533 passed, 0 failed.

Rebase-Executor: Claude Opus 5 (Commander session, linux-primary)
GoKubar added a commit that referenced this pull request Sep 14, 2026
`main` advanced by 16 commits while the first re-pin was being measured, five
of them in `crates/compiler`, so `c1ae760d` was already stale. Re-exported at
`e44d5917`, which also carries #339 (`\langle`/`\rangle` as U+27E8/U+27E9
mathopen/mathclose -- the corpus's `twelvept-plain` fixture was reporting "no
math glyph for '<'" and drawing an empty box), #321 (`\pagestyle`,
`\thispagestyle`, `\pagenumbering` in the preamble), #244 (`\maketitle`
without `\author`), #314 (`\odot`/`\ominus`/`\oslash`/`\bigcirc` as binary
operators) and #331 (siunitx `S[...]`/`s` columns) on top of #380's natbib.

Byte-identity re-verified at the new SHA the same two ways: the vendored
tree's path/mode/blob-SHA listing matches `git ls-tree -r
e44d591:crates/compiler` on all 555 files, and `diff -r --exclude=PIN`
against a fresh re-extraction is empty.

The no-other-directory-needs-re-pinning finding was re-checked against the new
`main` rather than carried over: `math-layout`, `paragraph-layout`,
`microtype`, `document-style`, `font-resources`, `tex-text-encoding`,
`tex-boxes`, `tex-expansion` and `vector-graphics` are still byte-identical to
`main`'s crates, and `font-engine`/`pdf`/`project-files` still differ only by
their own rows' deliberate choices.

Gates re-run at this pin, same font environment:

  cargo test --release on crates/render-pipeline   254 passed, 0 failed, 2 ignored
  amsmath corpus                                   59/59 within 0.5 bp
  tabular corpus                                   106/106 (words 0.5 bp, rules 0.1 bp)
  HW1 render                                       3 pages, 0 errors
  HW2 render                                       3 pages, 0 errors

Zero font-failure diagnostics on either HW document; the only diagnostics
remain `math_resource_profile` (4 on HW1, 7 on HW2), which are informational.

PR #385 (hyperref/`\hypersetup` and url.sty URL breaking) is still OPEN and so
is still deliberately absent from this pin.

Implementation-Agent: Claude Opus 5 (lane nixos-vendor-repin, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
@GoKubar

GoKubar commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #388: same commit rebased onto main after #317, #322, #331, #339, #333 and #345 landed. The two conflicts were mechanical — the \hypersetup match arm sits beside #322's \pagestyle/\thispagestyle/\pagenumbering arms, and the generated docs/user/compiler.md + supported-latex.json + coverage.md were regenerated with crates/compiler/scripts/render_supported_latex.sh, not hand-merged. Closing this one in favour of #388.

@GoKubar GoKubar closed this Sep 14, 2026
GoKubar added a commit that referenced this pull request Sep 14, 2026
… natbib (#386)

* render-pipeline: re-pin vendor/compiler to main so the corpus can see natbib

`crates/render-pipeline/vendor/*` are frozen `git archive` snapshots, so a
compiler-side change is invisible to `flashtex-render` -- and therefore to the
whole rendered corpus -- until the pin moves. `vendor/compiler` sat at
`f9bab2a7` (PR #267), one `crates/compiler` commit behind: PR #380
(`dd4a9809`, natbib citations and the `\bibitem[Author(Year)]` labels behind
them). #381 had already landed the render-pipeline half against the live
crate, so the corpus's `natbib-review` fixture was being measured against a
pipeline whose vendored compiler still could not parse `\citep`/`\citet`.

Re-exported from `main` at `c1ae760d`:

    git archive c1ae760:crates/compiler | tar -x -C vendor/compiler
    git rev-parse c1ae760 > vendor/compiler/PIN

Byte-identity verified two independent ways: a path/mode/blob-SHA listing of
the vendored tree matches `git ls-tree -r c1ae760:crates/compiler` on all 553
files, and `diff -r --exclude=PIN` against a fresh re-extraction is empty.

PR #385 (hyperref/`\hypersetup` and url.sty URL breaking -- the rebase of the
closed #379) was still OPEN when this pin was taken, so it is deliberately not
carried here: a vendor pin never holds an unmerged branch. It will arrive with
the next re-pin after it merges.

No other vendor directory needed re-pinning, and this was checked rather than
assumed. `crates/compiler`'s own path dependencies at `c1ae760d` are
`font-engine`, `tex-text-encoding`, `tex-boxes` and `tex-expansion`; a
recursive diff of every vendor directory against `main`'s crate of the same
name shows `math-layout`, `paragraph-layout`, `microtype`, `document-style`,
`font-resources`, `tex-text-encoding`, `tex-boxes` and `tex-expansion` already
byte-identical to `main`. `font-engine`, `pdf` and `project-files` do differ,
but each by its own VENDORING.md row's deliberate choice, and none of those
deltas is an API the new compiler needs -- the build and the full test run
below confirm it.

Also noted in the VENDORING.md row: that table's `compiler` and `math-layout`
cells still name `ea4ee5c8`, while the `PIN` files held `f9bab2a7` and
`9a82257b`. The table had drifted behind `PIN`; `PIN` is the authority. Only
the `compiler` row is corrected here, and by prepending -- the old log text is
kept intact.

Gates, all with `FLASHTEX_FONT_DIRS`/`FLASHTEX_TFM_DIRS` set to
`apps/mac/Fonts` and its lm + jknappen/ec + amsfonts/symbols TFM trees:

  cargo test --release on crates/render-pipeline   249 passed, 0 failed, 1 ignored
  amsmath corpus                                   59/59 within 0.5 bp
  tabular corpus                                   106/106 (words 0.5 bp, rules 0.1 bp)
  HW1 render                                       3 pages, 0 errors
  HW2 render                                       3 pages, 0 errors

Zero font-failure diagnostics on either HW document. The only diagnostics are
`math_resource_profile` (4 on HW1, 7 on HW2), which report that Latin Modern
Math supplies one 10 pt design for several optical sizes -- informational, not
a failure, and unchanged by this re-pin.

Implementation-Agent: Claude Opus 5 (lane nixos-vendor-repin, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>

* render-pipeline: move the vendor/compiler pin forward to current main

`main` advanced by 16 commits while the first re-pin was being measured, five
of them in `crates/compiler`, so `c1ae760d` was already stale. Re-exported at
`e44d5917`, which also carries #339 (`\langle`/`\rangle` as U+27E8/U+27E9
mathopen/mathclose -- the corpus's `twelvept-plain` fixture was reporting "no
math glyph for '<'" and drawing an empty box), #321 (`\pagestyle`,
`\thispagestyle`, `\pagenumbering` in the preamble), #244 (`\maketitle`
without `\author`), #314 (`\odot`/`\ominus`/`\oslash`/`\bigcirc` as binary
operators) and #331 (siunitx `S[...]`/`s` columns) on top of #380's natbib.

Byte-identity re-verified at the new SHA the same two ways: the vendored
tree's path/mode/blob-SHA listing matches `git ls-tree -r
e44d591:crates/compiler` on all 555 files, and `diff -r --exclude=PIN`
against a fresh re-extraction is empty.

The no-other-directory-needs-re-pinning finding was re-checked against the new
`main` rather than carried over: `math-layout`, `paragraph-layout`,
`microtype`, `document-style`, `font-resources`, `tex-text-encoding`,
`tex-boxes`, `tex-expansion` and `vector-graphics` are still byte-identical to
`main`'s crates, and `font-engine`/`pdf`/`project-files` still differ only by
their own rows' deliberate choices.

Gates re-run at this pin, same font environment:

  cargo test --release on crates/render-pipeline   254 passed, 0 failed, 2 ignored
  amsmath corpus                                   59/59 within 0.5 bp
  tabular corpus                                   106/106 (words 0.5 bp, rules 0.1 bp)
  HW1 render                                       3 pages, 0 errors
  HW2 render                                       3 pages, 0 errors

Zero font-failure diagnostics on either HW document; the only diagnostics
remain `math_resource_profile` (4 on HW1, 7 on HW2), which are informational.

PR #385 (hyperref/`\hypersetup` and url.sty URL breaking) is still OPEN and so
is still deliberately absent from this pin.

Implementation-Agent: Claude Opus 5 (lane nixos-vendor-repin, linux-primary)
Commit-Executor: Claude Opus 5 (direct git, observed Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
@GoKubar
GoKubar deleted the agent/kabir-claude/hyperref-compiler-rebase 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.

1 participant