diff options
author | Waylan Limberg <waylan@gmail.com> | 2010-03-24 22:17:26 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2010-03-24 22:17:26 -0400 |
commit | 0c09523c55ab40ba628501740eec0423d4c87a86 (patch) | |
tree | 0b59dc0055298b415ac65158dc0525832c668f00 | |
parent | 1599e909fd5c7a80f51247d7232c7627693206e6 (diff) | |
download | markdown-0c09523c55ab40ba628501740eec0423d4c87a86.tar.gz markdown-0c09523c55ab40ba628501740eec0423d4c87a86.tar.bz2 markdown-0c09523c55ab40ba628501740eec0423d4c87a86.zip |
Fixed Ticket 60. The dd in definition lists can now not be indented on secondary lines.
-rw-r--r-- | markdown/extensions/def_list.py | 9 | ||||
-rw-r--r-- | tests/extensions/extra/simple_def-lists.html | 6 | ||||
-rw-r--r-- | tests/extensions/extra/simple_def-lists.txt | 6 |
3 files changed, 19 insertions, 2 deletions
diff --git a/markdown/extensions/def_list.py b/markdown/extensions/def_list.py index 73a1c85..bd04b03 100644 --- a/markdown/extensions/def_list.py +++ b/markdown/extensions/def_list.py @@ -27,6 +27,7 @@ class DefListProcessor(markdown.blockprocessors.BlockProcessor): """ Process Definition Lists. """ RE = re.compile(r'(^|\n)[ ]{0,3}:[ ]{1,3}(.*?)(\n|$)') + NO_INDENT_RE = re.compile(r'^[ ]{0,3}[^ :]') def test(self, parent, block): return bool(self.RE.search(block)) @@ -35,12 +36,16 @@ class DefListProcessor(markdown.blockprocessors.BlockProcessor): block = blocks.pop(0) m = self.RE.search(block) terms = [l.strip() for l in block[:m.start()].split('\n') if l.strip()] - d, theRest = self.detab(block[m.end():]) + block = block[m.end():] + no_indent = self.NO_INDENT_RE.match(block) + if no_indent: + d, theRest = (block, None) + else: + d, theRest = self.detab(block) if d: d = '%s\n%s' % (m.group(2), d) else: d = m.group(2) - #import ipdb; ipdb.set_trace() sibling = self.lastChild(parent) if not terms and sibling.tag == 'p': # The previous paragraph contains the terms diff --git a/tests/extensions/extra/simple_def-lists.html b/tests/extensions/extra/simple_def-lists.html index 278e1ec..9448773 100644 --- a/tests/extensions/extra/simple_def-lists.html +++ b/tests/extensions/extra/simple_def-lists.html @@ -34,4 +34,10 @@ line <strong>2</strong> of def 3</p> </ul> </dd> </dl> +<p>and more text.</p> +<dl> +<dt>term 4</dt> +<dd>def4 + line 2 of def 4</dd> +</dl> <p>final text.</p>
\ No newline at end of file diff --git a/tests/extensions/extra/simple_def-lists.txt b/tests/extensions/extra/simple_def-lists.txt index 20c028a..20e9afa 100644 --- a/tests/extensions/extra/simple_def-lists.txt +++ b/tests/extensions/extra/simple_def-lists.txt @@ -26,4 +26,10 @@ term *3* * > blockquote in list +and more text. + +term 4 +: def4 + line 2 of def 4 + final text. |