Allow escaping "<" in x-ref roles by a backslash.

This commit is contained in:
Georg Brandl
2010-03-01 14:36:08 +01:00
parent 21194f3b2b
commit 0f812e72f7
2 changed files with 5 additions and 2 deletions

View File

@@ -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()

View File

@@ -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