mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow escaping "<" in x-ref roles by a backslash.
This commit is contained in:
@@ -105,9 +105,9 @@ class XRefRole(object):
|
||||
else:
|
||||
domain, role = typ.split(':', 1)
|
||||
classes = ['xref', domain, '%s-%s' % (domain, role)]
|
||||
text = utils.unescape(text)
|
||||
# if the first character is a bang, don't cross-reference at all
|
||||
if text[0:1] == '!':
|
||||
text = utils.unescape(text)
|
||||
if self.fix_parens:
|
||||
text, tgt = self._fix_parens(env, False, text[1:], "")
|
||||
innernode = self.innernodeclass(rawtext, text, classes=classes)
|
||||
@@ -115,6 +115,8 @@ class XRefRole(object):
|
||||
is_ref=False)
|
||||
# split title and target in role content
|
||||
has_explicit_title, title, target = split_explicit_title(text)
|
||||
title = utils.unescape(title)
|
||||
text = utils.unescape(text)
|
||||
# fix-up title and target
|
||||
if self.lowercase:
|
||||
target = target.lower()
|
||||
|
||||
@@ -17,7 +17,8 @@ from docutils import nodes
|
||||
from sphinx import addnodes
|
||||
|
||||
|
||||
explicit_title_re = re.compile('^(.+?)\s*<(.*?)>$', re.DOTALL)
|
||||
# \x00 means the "<" was backslash-escaped
|
||||
explicit_title_re = re.compile(r'^(.+?)\s*(?<!\x00)<(.*?)>$', re.DOTALL)
|
||||
caption_ref_re = explicit_title_re # b/w compat alias
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user