diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-11-20 19:38:09 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-11-20 19:38:09 -0500 |
commit | 517d38e552e91ebbe527a0286d43dd1daa585bcc (patch) | |
tree | 24056de7d71aa3018a6b32237df22e71d2128af2 /markdown/treeprocessors.py | |
parent | 41ebca604f081d1bb798d3178f674e960a2e4ec1 (diff) | |
download | markdown-517d38e552e91ebbe527a0286d43dd1daa585bcc.tar.gz markdown-517d38e552e91ebbe527a0286d43dd1daa585bcc.tar.bz2 markdown-517d38e552e91ebbe527a0286d43dd1daa585bcc.zip |
Cleaned up recent refactor into a package from a single file.
Diffstat (limited to 'markdown/treeprocessors.py')
-rw-r--r-- | markdown/treeprocessors.py | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/markdown/treeprocessors.py b/markdown/treeprocessors.py index e8d7cd0..0ea0de2 100644 --- a/markdown/treeprocessors.py +++ b/markdown/treeprocessors.py @@ -277,26 +277,31 @@ class InlineProcessor(Treeprocessor): for element, lst in insertQueue: if element.text: - element.text = markdown.inlinepatterns.handleAttributes(element.text, element) + element.text = \ + markdown.inlinepatterns.handleAttributes(element.text, + element) i = 0 for newChild in lst: # Processing attributes if newChild.tail: - newChild.tail = markdown.inlinepatterns.handleAttributes(newChild.tail, - element) + newChild.tail = \ + markdown.inlinepatterns.handleAttributes(newChild.tail, + element) if newChild.text: - newChild.text = markdown.inlinepatterns.handleAttributes(newChild.text, - newChild) + newChild.text = \ + markdown.inlinepatterns.handleAttributes(newChild.text, + newChild) element.insert(i, newChild) i += 1 - return tree class PrettifyTreeprocessor(Treeprocessor): - """Add linebreaks to the html document.""" + """ Add linebreaks to the html document. """ + def _prettifyETree(self, elem): - """Recursively add linebreaks to ElementTree children.""" + """ Recursively add linebreaks to ElementTree children. """ + i = "\n" if markdown.isBlockLevel(elem.tag) and elem.tag not in ['code', 'pre']: if (not elem.text or not elem.text.strip()) \ @@ -311,7 +316,8 @@ class PrettifyTreeprocessor(Treeprocessor): elem.tail = i def run(self, root): - """.Add linebreaks to ElementTree root object.""" + """ Add linebreaks to ElementTree root object. """ + self._prettifyETree(root) # Do <br />'s seperately as they are often in the middle of # inline content and missed by _prettifyETree. |