Skip to content

Commit

Permalink
Remove trailing whitespace (fixes html5lib#18).
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnedders committed Apr 13, 2013
1 parent caec8e9 commit b7cce84
Show file tree
Hide file tree
Showing 36 changed files with 460 additions and 460 deletions.
4 changes: 2 additions & 2 deletions html5lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import, division, unicode_literals

"""
"""
HTML parsing library based on the WHATWG "HTML5"
specification. The parser is designed to be compatible with existing
HTML found in the wild and implements well-defined error recovery that
Expand All @@ -10,7 +10,7 @@
import html5lib
f = open("my_document.html")
tree = html5lib.parse(f)
tree = html5lib.parse(f)
"""
__version__ = "0.95-dev"
from .html5parser import HTMLParser, parse, parseFragment
Expand Down
8 changes: 4 additions & 4 deletions html5lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
EOF = None

E = {
"null-character":
"null-character":
_("Null character in input stream, replaced with U+FFFD."),
"invalid-codepoint":
"invalid-codepoint":
_("Invalid codepoint in stream."),
"incorrectly-placed-solidus":
_("Solidus (/) incorrectly placed in tag."),
Expand Down Expand Up @@ -378,7 +378,7 @@
(namespaces["html"], "iframe"),
# Note that image is commented out in the spec as "this isn't an
# element that can end up on the stack, so it doesn't matter,"
(namespaces["html"], "image"),
(namespaces["html"], "image"),
(namespaces["html"], "img"),
(namespaces["html"], "input"),
(namespaces["html"], "isindex"),
Expand Down Expand Up @@ -3069,7 +3069,7 @@
"ParseError":7
}

tagTokenTypes = frozenset((tokenTypes["StartTag"], tokenTypes["EndTag"],
tagTokenTypes = frozenset((tokenTypes["StartTag"], tokenTypes["EndTag"],
tokenTypes["EmptyTag"]))


Expand Down
6 changes: 3 additions & 3 deletions html5lib/filters/optionaltags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __iter__(self):
for previous, token, next in self.slider():
type = token["type"]
if type == "StartTag":
if (token["data"] or
if (token["data"] or
not self.is_optional_start(token["name"], previous, next)):
yield token
elif type == "EndTag":
Expand Down Expand Up @@ -123,10 +123,10 @@ def is_optional_end(self, tagname, next):
# there is no more content in the parent element.
if type in ("StartTag", "EmptyTag"):
return next["name"] in ('address', 'article', 'aside',
'blockquote', 'datagrid', 'dialog',
'blockquote', 'datagrid', 'dialog',
'dir', 'div', 'dl', 'fieldset', 'footer',
'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'header', 'hr', 'menu', 'nav', 'ol',
'header', 'hr', 'menu', 'nav', 'ol',
'p', 'pre', 'section', 'table', 'ul')
else:
return type == "EndTag" or type is None
Expand Down
100 changes: 50 additions & 50 deletions html5lib/html5parser.py

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions html5lib/ihatexml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

letter = " | ".join([baseChar, ideographic])

#Without the
name = " | ".join([letter, digit, ".", "-", "_", combiningCharacter,
#Without the
name = " | ".join([letter, digit, ".", "-", "_", combiningCharacter,
extender])
nameFirst = " | ".join([letter, "_"])

Expand All @@ -40,7 +40,7 @@ def charStringToList(chars):
break
if not foundMatch:
assert len(item) == 1

rv.append([ord(item)] * 2)
rv = normaliseCharList(rv)
return rv
Expand All @@ -62,7 +62,7 @@ def normaliseCharList(charList):

#We don't really support characters above the BMP :(
max_unicode = int("FFFF", 16)

def missingRanges(charList):
rv = []
if charList[0] != 0:
Expand Down Expand Up @@ -103,8 +103,8 @@ def escapeRegexp(string):

class InfosetFilter(object):
replacementRegexp = re.compile(r"U[\dA-F]{5,5}")
def __init__(self, replaceChars = None,
dropXmlnsLocalName = False,
def __init__(self, replaceChars = None,
dropXmlnsLocalName = False,
dropXmlnsAttrNs = False,
preventDoubleDashComments = False,
preventDashAtCommentEnd = False,
Expand All @@ -124,7 +124,7 @@ def coerceAttribute(self, name, namespace=None):
if self.dropXmlnsLocalName and name.startswith("xmlns:"):
warnings.warn("Attributes cannot begin with xmlns", DataLossWarning)
return None
elif (self.dropXmlnsAttrNs and
elif (self.dropXmlnsAttrNs and
namespace == "http:https://www.w3.org/2000/xmlns/"):
warnings.warn("Attributes cannot be in the xml namespace", DataLossWarning)
return None
Expand All @@ -140,7 +140,7 @@ def coerceComment(self, data):
warnings.warn("Comments cannot contain adjacent dashes", DataLossWarning)
data = data.replace("--", "- -")
return data

def coerceCharacters(self, data):
if self.replaceFormFeedCharacters:
for i in range(data.count("\x0C")):
Expand All @@ -166,7 +166,7 @@ def toXmlName(self, name):
replacement = self.getReplacementCharacter(char)
nameRestOutput = nameRestOutput.replace(char, replacement)
return nameFirstOutput + nameRestOutput

def getReplacementCharacter(self, char):
if char in self.replaceCache:
replacement = self.replaceCache[char]
Expand Down
Loading

0 comments on commit b7cce84

Please sign in to comment.