diff options
author | Tiago Serafim <tserafim@gmail.com> | 2013-02-09 16:51:17 -0200 |
---|---|---|
committer | Tiago Serafim <tserafim@gmail.com> | 2013-02-09 17:39:12 -0200 |
commit | 14f43d5a4c91ac13528f4c9eb8c6247fdafb0ea1 (patch) | |
tree | edcb6d7462d31d66dcc792ed5e84373187b1de14 /markdown/extensions/def_list.py | |
parent | 6c15c64df40b9ded3f5dea2e694905222791c1b6 (diff) | |
parent | 41cc055580d63ffb7eb2bbb6c88e121727d91d06 (diff) | |
download | markdown-14f43d5a4c91ac13528f4c9eb8c6247fdafb0ea1.tar.gz markdown-14f43d5a4c91ac13528f4c9eb8c6247fdafb0ea1.tar.bz2 markdown-14f43d5a4c91ac13528f4c9eb8c6247fdafb0ea1.zip |
Merge branch 'master' into admonition
Conflicts:
docs/extensions/index.txt
tests/extensions/test.cfg
Diffstat (limited to 'markdown/extensions/def_list.py')
-rw-r--r-- | markdown/extensions/def_list.py | 14 |
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' |