engine: hyperref colorlinks — colour \url/\href/\hyperlink text - #209
Merged
Conversation
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.
hyperref's
colorlinksoption colours a link's text (rather than drawing a border box around it). The coloured-text style is the one this engine can render — a colour already flows to both drivers through each glyph — so this wires the option end to end.What works now
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=…, allcolors=…}is a real primitive (hyperstyle.go) instead of a no-op stub.\usepackage[colorlinks,urlcolor=blue]{hyperref}routes its options through the same parser (as hyperref itself does), so the common arXiv form works too.\url/\hrefpaint their text in urlcolor and\hyperlinkin linkcolor (a\hypertargetdestination is not coloured). Values resolve through the colour model, so names,rgb/HTMLand xcolor!-mixes all work. With colorlinks off (hyperref's own default) links keep the surrounding colour.Latent bug fixed along the way
verbNodesnever stamped the current colour, so verbatim text —\verb,\url— ignored\color(\textcolor{red}{\verb|x|}rendered black). It now stampscurColorlike ordinary text, which is also what makes a coloured\urlwork.Also corrects the now-stale doc comments in
hyperlink.gothat claimed go-pdfkit has no link-annotation API (#198 added it).Verification
\href/\url/\hyperlinkunder colorlinks render the matching colour in the SVG (fill="#…") from both option forms; colorlinks off leaves them uncoloured; a\hypertargetdestination stays uncoloured. Full engine suite, the conformance ratchet (colour is orthogonal to the layout proxy),go vetandgofmtall green.🤖 Generated with Claude Code