Replace \r\n to \n in Transformer html. Fixes #48
This commit is contained in:
parent
6141f3a8a5
commit
85cadf7ed5
|
@ -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():
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Reference in New Issue