Skip to content

Commit 1fa604e

Browse files
committed
Fix a few cases where the spec has changed
--HG-- branch : svgmathml
1 parent f3c54fd commit 1fa604e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/html5lib/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@
295295
(namespaces["html"], "a"),
296296
(namespaces["html"], "b"),
297297
(namespaces["html"], "big"),
298+
(namespaces["html"], "code"),
298299
(namespaces["html"], "em"),
299300
(namespaces["html"], "font"),
300301
(namespaces["html"], "i"),

src/html5lib/html5parser.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from constants import scopingElements, formattingElements, specialElements
1919
from constants import headingElements, tableInsertModeElements
2020
from constants import cdataElements, rcdataElements, voidElements
21-
from constants import tokenTypes, ReparseException
22-
from constants import tokenTypes, namespaces
21+
from constants import tokenTypes, ReparseException, namespaces
2322

2423
def parse(doc, treebuilder="simpletree", encoding=None):
2524
tb = treebuilders.getTreeBuilder(treebuilder)
@@ -677,7 +676,7 @@ def __init__(self, parser, tree):
677676

678677
self. endTagHandler = utils.MethodDispatcher([
679678
("head", self.endTagHead),
680-
("br", self.endTagBr)
679+
(("br", "html", "body"), self.endTagHtmlBodyBr)
681680
])
682681
self.endTagHandler.default = self.endTagOther
683682

@@ -746,7 +745,7 @@ def endTagHead(self, token):
746745
assert node.name == "head", "Expected head got %s"%node.name
747746
self.parser.phase = self.parser.phases["afterHead"]
748747

749-
def endTagBr(self, token):
748+
def endTagHtmlBodyBr(self, token):
750749
self.anythingElse()
751750
self.parser.phase.processEndTag(token)
752751

@@ -775,7 +774,8 @@ def __init__(self, parser, tree):
775774
("head", self.startTagHead)
776775
])
777776
self.startTagHandler.default = self.startTagOther
778-
self.endTagHandler = utils.MethodDispatcher([("br", self.endTagBr)])
777+
self.endTagHandler = utils.MethodDispatcher([(("body", "html", "br"),
778+
self.endTagHtmlBodyBr)])
779779
self.endTagHandler.default = self.endTagOther
780780

781781
def processEOF(self):
@@ -811,7 +811,7 @@ def startTagOther(self, token):
811811
self.anythingElse()
812812
self.parser.phase.processStartTag(token)
813813

814-
def endTagBr(self, token):
814+
def endTagHtmlBodyBr(self, token):
815815
#This is not currently in the spec
816816
self.anythingElse()
817817
self.parser.phase.processEndTag(token)
@@ -1002,6 +1002,9 @@ def startTagPlaintext(self, token):
10021002
def startTagHeading(self, token):
10031003
if self.tree.elementInScope("p"):
10041004
self.endTagP(impliedTagToken("p"))
1005+
if self.tree.openElements[-1].name in headingElements:
1006+
self.parser.parseError("unexpected-start-tag", {"name": token["name"]})
1007+
self.tree.openElements.pop()
10051008
# Uncomment the following for IE7 behavior:
10061009
#
10071010
#for item in headingElements:
@@ -1586,7 +1589,8 @@ def startTagStyleScript(self, token):
15861589
self.startTagOther(token)
15871590

15881591
def startTagInput(self, token):
1589-
if "type" in token["data"] and token["data"]["type"].translate(asciiUpper2Lower) == "hidden" and "tainted" not in self.getCurrentTable()._flags:
1592+
if ("type" in token["data"] and
1593+
token["data"]["type"].translate(asciiUpper2Lower) == "hidden"):
15901594
self.parser.parseError("unexpected-hidden-input-in-table")
15911595
self.tree.insertElement(token)
15921596
# XXX associate with form

0 commit comments

Comments
 (0)