Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ae6c7d0

Browse filesBrowse files
committed
Fix parse.py after html5lib#257
1 parent 699276b commit ae6c7d0
Copy full SHA for ae6c7d0

File tree

1 file changed

+4
-9
lines changed
Filter options

1 file changed

+4
-9
lines changed

‎parse.py

Copy file name to clipboardExpand all lines: parse.py
+4-9Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def parse():
5555

5656
tokenizer = HTMLTokenizer
5757

58-
p = html5parser.HTMLParser(tree=treebuilder, tokenizer=tokenizer, debug=opts.log)
58+
p = html5parser.HTMLParser(tree=treebuilder, debug=opts.log)
5959

6060
if opts.fragment:
6161
parseMethod = p.parseFragment
@@ -96,7 +96,7 @@ def parse():
9696

9797
def run(parseMethod, f, encoding, scripting):
9898
try:
99-
document = parseMethod(f, encoding=encoding, scripting=scripting)
99+
document = parseMethod(f, override_encoding=encoding, scripting=scripting)
100100
except:
101101
document = None
102102
traceback.print_exc()
@@ -117,16 +117,14 @@ def printOutput(parser, document, opts):
117117
document.writexml(sys.stdout, encoding="utf-8")
118118
elif tb == "lxml":
119119
import lxml.etree
120-
sys.stdout.write(lxml.etree.tostring(document))
120+
sys.stdout.write(lxml.etree.tostring(document, encoding="unicode"))
121121
elif tb == "etree":
122-
sys.stdout.write(utils.default_etree.tostring(document))
122+
sys.stdout.write(utils.default_etree.tostring(document, encoding="unicode"))
123123
elif opts.tree:
124124
if not hasattr(document, '__getitem__'):
125125
document = [document]
126126
for fragment in document:
127127
print(parser.tree.testSerializer(fragment))
128-
elif opts.hilite:
129-
sys.stdout.write(document.hilite("utf-8"))
130128
elif opts.html:
131129
kwargs = {}
132130
for opt in serializer.HTMLSerializer.options:
@@ -188,9 +186,6 @@ def getOptParser():
188186
parser.add_option("", "--no-html", action="store_false", default=True,
189187
dest="html", help="Don't output html")
190188

191-
parser.add_option("", "--hilite", action="store_true", default=False,
192-
dest="hilite", help="Output as formatted highlighted code.")
193-
194189
parser.add_option("-c", "--encoding", action="store_true", default=False,
195190
dest="encoding", help="Print character encoding used")
196191

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.