aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2008-03-06 19:03:14 +0000
committerWaylan Limberg <waylan@gmail.com>2008-03-06 19:03:14 +0000
commitc33ffe7dcd587b6f174d9f40049f43e628926b91 (patch)
tree01b2fb63495d45118b943f746a4ed6ac2d63d917
parentc411dd7ee643ae2953997018358e319d16dcef6a (diff)
downloadmarkdown-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].
-rw-r--r--markdown.py13
-rw-r--r--tests/misc/CRLF_line_ends.html5
-rw-r--r--tests/misc/CRLF_line_ends.txt5
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>