diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-11-04 22:17:18 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-11-04 22:17:18 -0500 |
commit | 00f623253bc80e95921f6055a6db206b548857db (patch) | |
tree | e8b0ab1f6efa50b0e0d7a1a5e0f048e2dac35b98 /markdown_extensions | |
parent | 47c8ba4a561d0100feebca93ff0f288757e6e69d (diff) | |
download | markdown-00f623253bc80e95921f6055a6db206b548857db.tar.gz markdown-00f623253bc80e95921f6055a6db206b548857db.tar.bz2 markdown-00f623253bc80e95921f6055a6db206b548857db.zip |
Fixed Definition List extension to not wrap the content of defs in p tags when appropriate.
Diffstat (limited to 'markdown_extensions')
-rw-r--r-- | markdown_extensions/def_list.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/markdown_extensions/def_list.py b/markdown_extensions/def_list.py index 30e0f82..dcab3ed 100644 --- a/markdown_extensions/def_list.py +++ b/markdown_extensions/def_list.py @@ -105,11 +105,14 @@ class DefListParser(markdown.MarkdownParser): if c and c[-1].tag == "p" and c[-1].text: terms = c[-1].text.split("\n") parent_elem.remove(c[-1]) + looseList = 1 # check for extra paragraphs of a def extradef, lines = self.detectTabbed(lines) - defs[-1].extend(extradef) + if extradef: + looseList = 1 + defs[-1].extend(extradef) # process the terms and defs - self._processDef(parent_elem, terms, defs) + self._processDef(parent_elem, terms, defs, looseList) if len(paragraph): self._MarkdownParser__processParagraph(parent_elem, paragraph, @@ -145,7 +148,7 @@ class DefListParser(markdown.MarkdownParser): return Def return [] - def _processDef(self, parentElem, terms, defs): + def _processDef(self, parentElem, terms, defs, looseList): children = parentElem.getchildren() if children and children[-1].tag == "dl": dl = children[-1] @@ -156,11 +159,11 @@ class DefListParser(markdown.MarkdownParser): dt.text = term for d in defs: dd = etree.SubElement(dl, "dd") - self.parseChunk(dd, d) + self.parseChunk(dd, d, looseList = looseList) def _MarkdownParser__processParagraph(self, parentElem, paragraph, inList, looseList): - if ( parentElem.tag == 'li' + if ((parentElem.tag == 'li' or parentElem.tag == 'dd') and not (looseList or parentElem.getchildren())): # If this is the first paragraph inside "li", don't |