aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Yunusov <nedrlab@gmail.com>2008-07-09 02:15:54 +0500
committerArtem Yunusov <nedrlab@gmail.com>2008-07-09 02:15:54 +0500
commit54a6d381a1a92210f3e619f7b2910b38a0568f9c (patch)
treef21c8d2217abfad06b9eb2b3a7f81567d4a35aba
parent040ab586847b8c652a72b4eaee4d321d14348c17 (diff)
downloadmarkdown-54a6d381a1a92210f3e619f7b2910b38a0568f9c.tar.gz
markdown-54a6d381a1a92210f3e619f7b2910b38a0568f9c.tar.bz2
markdown-54a6d381a1a92210f3e619f7b2910b38a0568f9c.zip
Unicode bug fix, stripping top level tags, small changes with identation.
-rw-r--r--markdown.py15
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)