diff --git a/sphinx/roles.py b/sphinx/roles.py index d20898fff..50c76df1a 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -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() diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 13fa3c10a..04185436d 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -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*(?$', re.DOTALL) caption_ref_re = explicit_title_re # b/w compat alias