summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-08-11 21:17:30 +0200
committerGeorg Brandl <georg@python.org>2009-08-11 21:17:30 +0200
commit43b0f0519a9d14a32e0607b79035f67bbe70a01b (patch)
treeda4730b9568c009eaa4bbf5f52d55eb5d3c8a2d4 /sphinx/util
parentcc6fb3d54926794ec20124b7f9e58956057f61d2 (diff)
downloadsphinx-43b0f0519a9d14a32e0607b79035f67bbe70a01b.tar.gz
Simplify explicit title matching.
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/__init__.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
index 9d677233..72b2a9c8 100644
--- a/sphinx/util/__init__.py
+++ b/sphinx/util/__init__.py
@@ -28,7 +28,8 @@ import sphinx
# Generally useful regular expressions.
ws_re = re.compile(r'\s+')
-caption_ref_re = re.compile(r'^([^<]+?)\s*<(.+)>$')
+explicit_title_re = re.compile('^(.+?)\s*<(.*?)>$')
+caption_ref_re = explicit_title_re # b/w compat alias
url_re = re.compile(r'(?P<schema>.+)://.*')
# SEP separates path elements in the canonical file names
@@ -437,21 +438,13 @@ def copy_static_entry(source, target, builder, context={}):
shutil.copytree(source, target)
+
def split_explicit_title(text):
"""Split role content into title and target, if given."""
- brace = text.find('<')
- if brace != -1:
- m = caption_ref_re.match(text)
- if m:
- target = m.group(2)
- title = m.group(1)
- else:
- # fallback: everything after '<' is the target
- target = text[brace+1:]
- title = text[:brace]
- return True, title, target
- else:
- return False, text, text
+ match = explicit_title_re.match(text)
+ if match:
+ return True, m.group(1), m.group(2)
+ return False, text, text
# monkey-patch Node.traverse to get more speed
# traverse() is called so many times during a build that it saves