From 0c09523c55ab40ba628501740eec0423d4c87a86 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 24 Mar 2010 22:17:26 -0400 Subject: Fixed Ticket 60. The dd in definition lists can now not be indented on secondary lines. --- markdown/extensions/def_list.py | 9 +++++++-- tests/extensions/extra/simple_def-lists.html | 6 ++++++ 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 2 of def 3

+

and more text.

+
+
term 4
+
def4 + line 2 of def 4
+

final text.

\ 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. -- cgit v1.2.3