Skip to content

Commit

Permalink
LaTeX: allow hyperlinks from inside titles
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbu committed Aug 26, 2024
1 parent 53f8edf commit 28f46ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions sphinx/texinputs/sphinxlatexstyletext.sty
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@
\newenvironment{sphinxlegend}{\par\small}{\par}
% reduce hyperref "Token not allowed in a PDF string" warnings on PDF builds
\AtBeginDocument{\pdfstringdefDisableCommands{%
% all "protected" macros possibly ending up in section titles should be here
% TODO: examine if \sphinxhref, \sphinxurl, \sphinnolinkurl should be handled
\def\sphinxurl {\url}%
\def\sphinxnolinkurl {\nolinkurl}%
\let\sphinxhref \@secondoftwo
\let\sphinxstyleemphasis \@firstofone
\let\sphinxstyleliteralemphasis \@firstofone
\let\sphinxstylestrong \@firstofone
Expand Down
3 changes: 2 additions & 1 deletion sphinx/writers/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,8 @@ def visit_reference(self, node: Element) -> None:
uri = node.get('refuri', '')
if not uri and node.get('refid'):
uri = '%' + self.curfilestack[-1] + '#' + node['refid']
if self.in_title or not uri:
if not uri:
print(node)

Check failure on line 1815 in sphinx/writers/latex.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (T201)

sphinx/writers/latex.py:1815:13: T201 `print` found
self.context.append('')
elif uri.startswith('#'):
# references to labels in the same document
Expand Down

0 comments on commit 28f46ca

Please sign in to comment.