diff --git a/CHANGES b/CHANGES index 1319812cf..a43e0b5d0 100644 --- a/CHANGES +++ b/CHANGES @@ -114,6 +114,7 @@ Bugs fixed * #6165: autodoc: ``tab_width`` setting of docutils has been ignored * #6311: autosummary: autosummary table gets confused by complex type hints * Generated Makefiles lack a final EOL (refs: #6232) +* #6375: extlinks: Cannot escape angle brackets in link caption Testing -------- diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 60e0144b0..58c6a6698 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -31,7 +31,7 @@ logger = logging.getLogger(__name__) # \x00 means the "<" was backslash-escaped -explicit_title_re = re.compile(r'^(.+?)\s*(?$', re.DOTALL) +explicit_title_re = re.compile(r'^(.+?)\s*(?$', re.DOTALL) caption_ref_re = explicit_title_re # b/w compat alias diff --git a/tests/test_util_nodes.py b/tests/test_util_nodes.py index c83fda36f..1a2ded447 100644 --- a/tests/test_util_nodes.py +++ b/tests/test_util_nodes.py @@ -17,7 +17,7 @@ from docutils.parsers import rst from docutils.utils import new_document from sphinx.transforms import ApplySourceWorkaround -from sphinx.util.nodes import NodeMatcher, extract_messages, clean_astext +from sphinx.util.nodes import NodeMatcher, extract_messages, clean_astext, split_explicit_title def _transform(doctree): @@ -178,3 +178,18 @@ def test_clean_astext(): node = nodes.paragraph(text='hello world') node += nodes.raw('', 'raw text', format='html') assert 'hello world' == clean_astext(node) + + +@pytest.mark.parametrize( + 'title, expected', + [ + # implicit + ('hello', (False, 'hello', 'hello')), + # explicit + ('hello ', (True, 'hello', 'world')), + # explicit (title having angle brackets) + ('hello ', (True, 'hello ', 'sphinx')), + ] +) +def test_split_explicit_target(title, expected): + assert expected == split_explicit_title(title)