Skip to content

Allow self closing <col /> tags. #244

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ Patches and suggestions
- Jim Baker
- Michael[tm] Smith
- Marc Abramowitz
- Jon Dufresne
9 changes: 6 additions & 3 deletions html5lib/html5parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ def mainLoop(self):
ParseErrorToken = tokenTypes["ParseError"]

for token in self.normalizedTokens():
prev_token = None
new_token = token
while new_token is not None:
prev_token = new_token
currentNode = self.tree.openElements[-1] if self.tree.openElements else None
currentNodeNamespace = currentNode.namespace if currentNode else None
currentNodeName = currentNode.name if currentNode else None
Expand Down Expand Up @@ -211,10 +213,10 @@ def mainLoop(self):
elif type == DoctypeToken:
new_token = phase.processDoctype(new_token)

if (type == StartTagToken and token["selfClosing"] and
not token["selfClosingAcknowledged"]):
if (type == StartTagToken and prev_token["selfClosing"] and
not prev_token["selfClosingAcknowledged"]):
self.parseError("non-void-element-with-trailing-solidus",
{"name": token["name"]})
{"name": prev_token["name"]})

# When the loop finishes it's EOF
reprocess = True
Expand Down Expand Up @@ -1933,6 +1935,7 @@ def processCharacters(self, token):
def startTagCol(self, token):
self.tree.insertElement(token)
self.tree.openElements.pop()
token["selfClosingAcknowledged"] = True

def startTagOther(self, token):
ignoreEndTag = self.ignoreEndTagColgroup()
Expand Down
6 changes: 6 additions & 0 deletions html5lib/tests/test_parser2.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,9 @@ def test_debug_log():
def test_no_duplicate_clone():
frag = parseFragment("<b><em><foo><foob><fooc><aside></b></em>")
assert len(frag) == 2


def test_self_closing_col():
parser = HTMLParser()
parser.parseFragment('<table><colgroup><col /></colgroup></table>')
assert not parser.errors