engine: \href becomes a clickable /Link annotation in the PDF - #198
Merged
Conversation
The PDF driver drew a hyperlink's text but not a clickable rectangle, because go-pdfkit had no link-annotation API; \href/\url were live in the SVG (<a href>) but inert in the PDF. go-pdfkit v0.7.0 adds Page.AddLink, so pdfDraw.link now places a /Link annotation over the inner box — engine-top-down (x, baseline-height) .. (x+width, baseline+depth), flipped into PDF y-up default user space — carrying the URL as a URI action. Bumps go-pdfkit v0.6.0 -> v0.7.0. Verified end-to-end: a rendered \href PDF now carries /Annots //Link //URI with the target URL; full engine suite green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Sep 3, 2026
tannevaled
added a commit
that referenced
this pull request
Sep 3, 2026
hyperref's colorlinks option colours a link's text (rather than drawing a border
box around it); the coloured-text style is the one this engine can render, since a
colour already flows to both drivers through each glyph. So this wires the option
end to end:
- \hypersetup{colorlinks=true, urlcolor=blue, linkcolor=..., allcolors=...} is
now a real primitive (hyperstyle.go) instead of a no-op stub, parsing the
keyval and recording the options that change visible output.
- The package-option form \usepackage[colorlinks,urlcolor=blue]{hyperref} routes
its options through the same parser (as hyperref itself does), so the common
arXiv form works too.
- With colorlinks on, \url and \href paint their text in urlcolor and \hyperlink
in linkcolor (a \hypertarget destination is not coloured); values resolve
through the colour model, so names, rgb/HTML and xcolor mixes all work. With
colorlinks off (hyperref's default) links keep the surrounding colour.
Also fixes a latent bug this surfaced: verbNodes never stamped the current colour,
so verbatim text — \verb, \url — ignored \color entirely (\textcolor{red}{\verb|x|}
rendered black). It now stamps curColor like ordinary text.
Corrects the now-stale doc comments in hyperlink.go that claimed go-pdfkit has no
link-annotation API (PR #198 added it).
Verified: \href/\url/\hyperlink under colorlinks render the matching colour in the
SVG (fill="#…") from both the \hypersetup and package-option forms; colorlinks off
leaves them uncoloured; a \hypertarget destination stays uncoloured; full engine
suite, the conformance ratchet, go vet and gofmt all green.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The PDF driver drew a hyperlink's text but not a clickable rectangle, because go-pdfkit had no link-annotation API — so
\href/\urlwere live in the SVG (<a href>) but inert in the PDF.How
go-pdfkit v0.7.0 adds
Page.AddLink(go-pdfkit/pdfkit#21).pdfDraw.linknow places a/Linkannotation over the inner box — engine-top-down(x, baseline-height) .. (x+width, baseline+depth), flipped into PDF y-up default user space — carrying the URL as a URI action. Bumpsgo-pdfkitv0.6.0 → v0.7.0.Verification
End-to-end test: a rendered
\hrefPDF now carries/Annots·/Link·/URIwith the target URL. Full engine suite,go vet,gofmtgreen; rebased onto #196.Closes the "clickable PDF links" documented gap.
🤖 Generated with Claude Code