diff options
-rw-r--r-- | markdown.py | 13 | ||||
-rw-r--r-- | tests/misc/CRLF_line_ends.html | 5 | ||||
-rw-r--r-- | tests/misc/CRLF_line_ends.txt | 5 |
3 files changed, 16 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) diff --git a/tests/misc/CRLF_line_ends.html b/tests/misc/CRLF_line_ends.html new file mode 100644 index 0000000..8e6849f --- /dev/null +++ b/tests/misc/CRLF_line_ends.html @@ -0,0 +1,5 @@ +<p>foo +</p> +<div> +bar +</div>
\ No newline at end of file diff --git a/tests/misc/CRLF_line_ends.txt b/tests/misc/CRLF_line_ends.txt new file mode 100644 index 0000000..7d5e324 --- /dev/null +++ b/tests/misc/CRLF_line_ends.txt @@ -0,0 +1,5 @@ +foo
+
+<div>
+bar
+</div>
|