From ef7f528adeceaa4a47d30fe105d928823d9c808f Mon Sep 17 00:00:00 2001 From: tristanlatr Date: Sat, 2 Mar 2024 14:21:55 -0500 Subject: [PATCH] Fix bug with link spanning on several lines --- pydoctor/epydoc/markup/epytext.py | 3 ++- pydoctor/node2stan.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pydoctor/epydoc/markup/epytext.py b/pydoctor/epydoc/markup/epytext.py index 3a7497dee..721fb7f23 100644 --- a/pydoctor/epydoc/markup/epytext.py +++ b/pydoctor/epydoc/markup/epytext.py @@ -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)) diff --git a/pydoctor/node2stan.py b/pydoctor/node2stan.py index 4457c8a4c..9bd34d75c 100644 --- a/pydoctor/node2stan.py +++ b/pydoctor/node2stan.py @@ -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('(')