Skip to content

Commit

Permalink
Fix bug with link spanning on several lines
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr committed Mar 2, 2024
1 parent 6971745 commit ef7f528
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pydoctor/epydoc/markup/epytext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,8 @@ def _colorize_link(link: Element, token: Token, end: int, errors: List[ParseErro
# Here we used to process the target in order to remove arg lists for functions
# and validate it. But now this happens in node2stan.parse_reference().
# The target is not validated anymore since the intersphinx taget names can contain any kind of text.
pass
# We simply normalize it.
target = re.sub(r'\s', ' ', target)

# Construct the target element.
target_elt = Element('target', target, lineno=str(token.startline))
Expand Down
6 changes: 4 additions & 2 deletions pydoctor/node2stan.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ def parse_reference(node:nodes.Node) -> Reference:
label, target = node.children, node.attributes['refuri']
else:
# RST parsed.
m = _TARGET_RE.match(node.astext())
# Sanitize links spaning over multiple lines
node_text = re.sub(r'\s', ' ', node.astext())
m = _TARGET_RE.match(node_text)
if m:
label, target = m.groups()
else:
label = target = node.astext()
label = target = node_text
# Support linking to functions and methods with parameters
try:
begin_parameters = target.index('(')
Expand Down

0 comments on commit ef7f528

Please sign in to comment.