diff options
author | Waylan Limberg <waylan@gmail.com> | 2008-03-06 19:03:14 +0000 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2008-03-06 19:03:14 +0000 |
commit | c33ffe7dcd587b6f174d9f40049f43e628926b91 (patch) | |
tree | 01b2fb63495d45118b943f746a4ed6ac2d63d917 /markdown.py | |
parent | c411dd7ee643ae2953997018358e319d16dcef6a (diff) | |
download | markdown-c33ffe7dcd587b6f174d9f40049f43e628926b91.tar.gz markdown-c33ffe7dcd587b6f174d9f40049f43e628926b91.tar.bz2 markdown-c33ffe7dcd587b6f174d9f40049f43e628926b91.zip |
Moved line-endings cleanup from transform to convert method so it runs prior to textPreprocessors. Raw HTML with CRLF line endings now works properly. Also added a test. Fixes [1908691].
Diffstat (limited to 'markdown.py')
-rw-r--r-- | markdown.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/markdown.py b/markdown.py index 97038ba..3dc8f00 100644 --- a/markdown.py +++ b/markdown.py @@ -1282,16 +1282,10 @@ class Markdown: self.top_element.setAttribute('class', 'markdown') self.doc.appendChild(self.top_element) - # Fixup the source text - text = self.source - text = text.replace("\r\n", "\n").replace("\r", "\n") - text += "\n\n" - text = text.expandtabs(TAB_LENGTH) - # Split into lines and run the preprocessors that will work with # self.lines - self.lines = text.split("\n") + self.lines = self.source.split("\n") # Run the pre-processors on the lines for prep in self.preprocessors : @@ -1727,6 +1721,11 @@ class Markdown: message(CRITICAL, 'UnicodeDecodeError: Markdown only accepts unicode or ascii input.') return u"" + # Fixup the source text + self.source = self.source.replace("\r\n", "\n").replace("\r", "\n") + self.source += "\n\n" + self.source = self.source.expandtabs(TAB_LENGTH) + for pp in self.textPreprocessors: self.source = pp.run(self.source) |