Skip to content

Commit

Permalink
Remove the tokenizer's unused case-converting options
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnedders committed Jul 6, 2016
1 parent d8d5bb6 commit 6464fc4
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions html5lib/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ class HTMLTokenizer(object):
Points to HTMLInputStream object.
"""

def __init__(self, stream, encoding=None, useChardet=True,
lowercaseElementName=True, lowercaseAttrName=True, parser=None):
def __init__(self, stream, encoding=None, useChardet=True, parser=None):

self.stream = HTMLInputStream(stream, encoding, True, useChardet)
self.parser = parser

# Perform case conversions?
self.lowercaseElementName = lowercaseElementName
self.lowercaseAttrName = lowercaseAttrName

# Setup the initial tokenizer state
self.escapeFlag = False
self.lastFourChars = []
Expand Down Expand Up @@ -232,8 +227,7 @@ def emitCurrentToken(self):
token = self.currentToken
# Add token to the queue to be yielded
if (token["type"] in tagTokenTypes):
if self.lowercaseElementName:
token["name"] = token["name"].translate(asciiUpper2Lower)
token["name"] = token["name"].translate(asciiUpper2Lower)
if token["type"] == tokenTypes["EndTag"]:
if token["data"]:
self.tokenQueue.append({"type": tokenTypes["ParseError"],
Expand Down Expand Up @@ -918,9 +912,8 @@ def attributeNameState(self):
# Attributes are not dropped at this stage. That happens when the
# start tag token is emitted so values can still be safely appended
# to attributes, but we do want to report the parse error in time.
if self.lowercaseAttrName:
self.currentToken["data"][-1][0] = (
self.currentToken["data"][-1][0].translate(asciiUpper2Lower))
self.currentToken["data"][-1][0] = (
self.currentToken["data"][-1][0].translate(asciiUpper2Lower))
for name, _ in self.currentToken["data"][:-1]:
if self.currentToken["data"][-1][0] == name:
self.tokenQueue.append({"type": tokenTypes["ParseError"], "data":
Expand Down

0 comments on commit 6464fc4

Please sign in to comment.