Created
May 29, 2012 16:35
-
-
Save bukzor/2829431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import lxml.html.defs | |
lxml.html.defs.empty_tags = lxml.html.defs.empty_tags.union(['wbr']) | |
reload(lxml.html) | |
reload(lxml) | |
print '<wbr> is empty tag:', 'wbr' in lxml.html.defs.empty_tags | |
from lxml import etree | |
from cStringIO import StringIO | |
wbr_html = """\ | |
<html> | |
<head> | |
<title>wbr test</title> | |
</head> | |
<body> | |
Test for a breakable<wbr>word implemenation change | |
</body> | |
</html> | |
""" | |
parser = etree.HTMLParser() | |
tree = etree.parse(StringIO(wbr_html), parser) | |
result = etree.tostring(tree.getroot(), pretty_print=True, method="html") | |
if result.split() != wbr_html.split(): # split, as we are not interested in whitespace differences | |
print(result) | |
print("not ok") | |
else: | |
print("OK") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: