Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions sphinx/writers/manpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ def visit_image(self, node: Element) -> None:
# overwritten -- don't visit inner marked up nodes
def visit_reference(self, node: Element) -> None:
uri = node.get('refuri', '')
if uri:
is_safe_to_click = uri.startswith(('mailto:', 'http:', 'https:', 'ftp:'))
if is_safe_to_click:
# OSC 8 link start (using groff's device control directive).
self.body.append(fr"\X'tty: link {uri}'")

Expand All @@ -319,7 +320,7 @@ def visit_reference(self, node: Element) -> None:
self.visit_Text(node)
self.body.append(self.defs['reference'][1])

if uri.startswith(('mailto:', 'http:', 'https:', 'ftp:')):
if uri and not uri.startswith('#'):
# if configured, put the URL after the link
if self.config.man_show_urls and node.astext() != uri:
if uri.startswith('mailto:'):
Expand All @@ -328,7 +329,7 @@ def visit_reference(self, node: Element) -> None:
' <',
self.defs['strong'][0], uri, self.defs['strong'][1],
'>'])
if uri:
if is_safe_to_click:
# OSC 8 link end.
self.body.append(r"\X'tty: link'")
raise nodes.SkipNode
Expand Down