diff options
author | Artem Yunusov <nedrlab@gmail.com> | 2008-07-09 02:15:54 +0500 |
---|---|---|
committer | Artem Yunusov <nedrlab@gmail.com> | 2008-07-09 02:15:54 +0500 |
commit | 54a6d381a1a92210f3e619f7b2910b38a0568f9c (patch) | |
tree | f21c8d2217abfad06b9eb2b3a7f81567d4a35aba /markdown.py | |
parent | 040ab586847b8c652a72b4eaee4d321d14348c17 (diff) | |
download | markdown-54a6d381a1a92210f3e619f7b2910b38a0568f9c.tar.gz markdown-54a6d381a1a92210f3e619f7b2910b38a0568f9c.tar.bz2 markdown-54a6d381a1a92210f3e619f7b2910b38a0568f9c.zip |
Unicode bug fix, stripping top level tags, small changes with identation.
Diffstat (limited to 'markdown.py')
-rw-r--r-- | markdown.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/markdown.py b/markdown.py index 3db723d..f3f2481 100644 --- a/markdown.py +++ b/markdown.py @@ -86,15 +86,16 @@ except ImportError: "Failed to import ElementTree from any known place") sys.exit(1)''' -import xml.etree.cElementTree as etree -#from lxml import etree +import xml.etree.cElementTree as etree def indentETree(elem, level=0): + if level > 1: - i = "\n" + level*" " + i = "\n" + (level-1)*" " else: i = "\n" + if len(elem): if not elem.text or not elem.text.strip(): elem.text = i + " " @@ -1885,11 +1886,11 @@ class Markdown: root = self.applyInlinePatterns(tree).getroot() indentETree(root) + + xml = codecs.decode(etree.tostring(root, encoding="utf8"), "utf8") - xml = etree.tostring(root, encoding="utf8") - - '''if self.stripTopLevelTags: - xml = xml.strip()[44:-7] + "\n"''' + if self.stripTopLevelTags: + xml = xml.strip()[44:-7] + "\n" for pp in self.textPostprocessors: xml = pp.run(xml) |