aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/extensions/def_list.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2013-02-06 13:42:03 -0500
committerWaylan Limberg <waylan@gmail.com>2013-02-06 13:42:03 -0500
commitfdfa88b77eff39cda4716fdb49444f5e56d144ac (patch)
tree5eaf315fd910001cb8b5fff306d604dd487fad4c /markdown/extensions/def_list.py
parent0b4ffbb60ef4a81cc6e5606ac40a42380077a690 (diff)
downloadmarkdown-fdfa88b77eff39cda4716fdb49444f5e56d144ac.tar.gz
markdown-fdfa88b77eff39cda4716fdb49444f5e56d144ac.tar.bz2
markdown-fdfa88b77eff39cda4716fdb49444f5e56d144ac.zip
Account for a paragraph that starts with a colon when processing def_lists
Fixes #171. While that report provided an example of an unordered list item that started with a colon, any block that starts with a colon and has no siblings before it (paragraph as begining if document, list item, etc) all exhibit this same behavior. Following PHP Markdown Extra's lead, these are not definition items as they have no term before them.
Diffstat (limited to 'markdown/extensions/def_list.py')
-rw-r--r--markdown/extensions/def_list.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/markdown/extensions/def_list.py b/markdown/extensions/def_list.py
index da1726a..382445c 100644
--- a/markdown/extensions/def_list.py
+++ b/markdown/extensions/def_list.py
@@ -34,10 +34,11 @@ class DefListProcessor(markdown.blockprocessors.BlockProcessor):
return bool(self.RE.search(block))
def run(self, parent, blocks):
- block = blocks.pop(0)
- m = self.RE.search(block)
- terms = [l.strip() for l in block[:m.start()].split('\n') if l.strip()]
- block = block[m.end():]
+
+ raw_block = blocks.pop(0)
+ m = self.RE.search(raw_block)
+ terms = [l.strip() for l in raw_block[:m.start()].split('\n') if l.strip()]
+ block = raw_block[m.end():]
no_indent = self.NO_INDENT_RE.match(block)
if no_indent:
d, theRest = (block, None)
@@ -48,6 +49,11 @@ class DefListProcessor(markdown.blockprocessors.BlockProcessor):
else:
d = m.group(2)
sibling = self.lastChild(parent)
+ if not terms and sibling is None:
+ # This is not a definition item. Most likely a paragraph that
+ # starts with a colon at the begining of a document or list.
+ blocks.insert(0, raw_block)
+ return False
if not terms and sibling.tag == 'p':
# The previous paragraph contains the terms
state = 'looselist'