Skip to content

Commit 9fa1a28

Browse files
committed
improve error reporting a bit more
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40465
1 parent 5989ef7 commit 9fa1a28

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/html5parser.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def endTagHead(self, name):
463463
if self.tree.openElements[-1].name == "head":
464464
self.tree.openElements.pop()
465465
else:
466-
self.parser.parseError()
466+
self.parser.parseError(_(u"Unexpected end tag (head). Ignored."))
467467
self.parser.phase = self.parser.phases["afterHead"]
468468

469469
def endTagHtml(self, name):
@@ -474,11 +474,11 @@ def endTagTitleStyleScript(self, name):
474474
if self.tree.openElements[-1].name == name:
475475
self.tree.openElements.pop()
476476
else:
477-
self.parser.parseError(_("Unexpected end tag (" + name +\
477+
self.parser.parseError(_(u"Unexpected end tag (" + name +\
478478
"). Ignored."))
479479

480480
def endTagOther(self, name):
481-
self.parser.parseError(_("Unexpected end tag (" + name +\
481+
self.parser.parseError(_(u"Unexpected end tag (" + name +\
482482
"). Ignored."))
483483

484484
def anythingElse(self):
@@ -517,7 +517,8 @@ def startTagFrameset(self, name, attributes):
517517
self.parser.phase = self.parser.phases["inFrameset"]
518518

519519
def startTagFromHead(self, name, attributes):
520-
self.parser.parseError()
520+
self.parser.parseError(_(u"Unexpected start tag (" + name +\
521+
") that belongs in head. Moved."))
521522
self.parser.phase = self.parser.phases["inHead"]
522523
self.parser.phase.processStartTag(name, attributes)
523524

@@ -618,12 +619,12 @@ def startTagScript(self, name, attributes):
618619
self.parser.phases["inHead"].processStartTag(name, attributes)
619620

620621
def startTagFromHead(self, name, attributes):
621-
self.parser.parseError(_("Unexpected start tag " + name +\
622-
" that belongs in the head. Moved."))
622+
self.parser.parseError(_(u"Unexpected start tag (" + name +\
623+
") that belongs in the head. Moved."))
623624
self.parser.phases["inHead"].processStartTag(name, attributes)
624625

625626
def startTagBody(self, name, attributes):
626-
self.parser.parseError(_("Unexpected start tag body"))
627+
self.parser.parseError(_(u"Unexpected start tag (body)."))
627628
if len(self.tree.openElements) == 1 \
628629
or self.tree.openElements[1].name != "body":
629630
assert self.parser.innerHTML
@@ -687,7 +688,8 @@ def startTagHeading(self, name, attributes):
687688
def startTagA(self, name, attributes):
688689
afeAElement = self.tree.elementInActiveFormattingElements("a")
689690
if afeAElement:
690-
self.parser.parseError()
691+
self.parser.parseError(_(u"Start tag a was in the list of active "
692+
"formatting elements."))
691693
self.endTagFormatting("a")
692694
if afeAElement in self.tree.openElements:
693695
self.tree.openElements.remove(afeAElement)
@@ -702,8 +704,8 @@ def startTagFormatting(self, name, attributes):
702704

703705
def startTagButton(self, name, attributes):
704706
if self.tree.elementInScope("button"):
705-
self.parser.parseError(_("Unexpected start tag button. Implying"
706-
"button end tag."))
707+
self.parser.parseError(_("Unexpected start tag (button) implied "
708+
"end tag (button)."))
707709
self.processEndTag("button")
708710
self.parser.phase.processStartTag(name, attributes)
709711
else:
@@ -740,8 +742,8 @@ def startTagHr(self, name, attributes):
740742

741743
def startTagImage(self, name, attributes):
742744
# No really...
743-
self.parser.parseError(_("Unexpected start tag image. Use img "
744-
"instead"))
745+
self.parser.parseError(_(u"Unexpected start tag (image). Treated "
746+
u"as img."))
745747
self.processStartTag("img", attributes)
746748

747749
def startTagInput(self, name, attributes):
@@ -793,8 +795,8 @@ def startTagMisplaced(self, name, attributes):
793795
"option", "optgroup", "tbody", "td", "tfoot", "th", "thead",
794796
"tr", "noscript"
795797
"""
796-
self.parser.parseError(_("Unexpected start tag (" + name +\
797-
"). Ignored."))
798+
self.parser.parseError(_(u"Unexpected start tag (" + name +\
799+
u"). Ignored."))
798800

799801
def startTagNew(self, name, other):
800802
"""New HTML5 elements, "event-source", "section", "nav",
@@ -835,7 +837,8 @@ def endTagBlock(self, name):
835837
if inScope:
836838
self.tree.generateImpliedEndTags()
837839
if self.tree.openElements[-1].name != name:
838-
self.parser.parseError()
840+
self.parser.parseError((u"End tag (" + name + ") seen too "
841+
u"early. Expected other end tag."))
839842
if inScope:
840843
node = self.tree.openElements.pop()
841844
while node.name != name:

0 commit comments

Comments
 (0)