Replace \r\n to \n in Transformer html. Fixes #48

This commit is contained in:
Sergey Lavrinenko 2015-04-01 23:10:52 +03:00
parent 6141f3a8a5
commit 85cadf7ed5
2 changed files with 10 additions and 1 deletions

View File

@ -29,6 +29,9 @@ def test_image_apply():
assert after in t.to_string()
def test_entity_13():
assert Transformer(html="<div>x\r\n</div>").to_string() == '<html><body><div>x\n</div></body></html>'
def test_link_apply():

View File

@ -63,7 +63,12 @@ class HTMLParser(object):
_xml_title_regex = re.compile(r'\<title(.*?)\/\>', re.IGNORECASE)
def __init__(self, html, method="html", output_method="xml"):
self._html = html
if output_method == 'xml':
self._html = html.replace('\r\n', '\n')
else:
self._html = html
self._method = method
self._output_method = output_method
self._tree = None
@ -334,6 +339,7 @@ class BaseTransformer(HTMLParser):
return self
class Transformer(BaseTransformer):
pass