Skip to content

Commit 01a198f

Browse files
committed
significantly improve the "No DOCTYPE seen." error messages
--HG-- extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%40481
1 parent 0d99a60 commit 01a198f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/html5parser.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class InitialPhase(Phase):
277277
# "quirks mode". It is expected that a future version of HTML5 will defin
278278
# this.
279279
def processEOF(self):
280-
self.parser.parseError(_("No DOCTYPE seen."))
280+
self.parser.parseError(_(u"Unexpected End of file. Expected DOCTYPE."))
281281
self.parser.phase = self.parser.phases["rootElement"]
282282
self.parser.phase.processEOF()
283283

@@ -286,25 +286,28 @@ def processComment(self, data):
286286

287287
def processDoctype(self, name, error):
288288
if error:
289-
self.parser.parseError(_("DOCTYPE is in error."))
289+
self.parser.parseError(_("Erroneous DOCTYPE."))
290290
self.tree.insertDoctype(name)
291291
self.parser.phase = self.parser.phases["rootElement"]
292292

293293
def processSpaceCharacters(self, data):
294294
self.tree.insertText(data, self.tree.document)
295295

296296
def processCharacters(self, data):
297-
self.parser.parseError(_("No DOCTYPE seen."))
297+
self.parser.parseError(_(u"Unexpected non-space characters. "
298+
u"Expected DOCTYPE."))
298299
self.parser.phase = self.parser.phases["rootElement"]
299300
self.parser.phase.processCharacters(data)
300301

301302
def processStartTag(self, name, attributes):
302-
self.parser.parseError(_("No DOCTYPE seen."))
303+
self.parser.parseError(_(u"Unexpected start tag (" + name +\
304+
u"). Expected DOCTYPE."))
303305
self.parser.phase = self.parser.phases["rootElement"]
304306
self.parser.phase.processStartTag(name, attributes)
305307

306308
def processEndTag(self, name):
307-
self.parser.parseError(_("No DOCTYPE seen."))
309+
self.parser.parseError(_(u"Unexpected end tag (" + name +\
310+
"). Expected DOCTYPE."))
308311
self.parser.phase = self.parser.phases["rootElement"]
309312
self.parser.phase.processEndTag(name)
310313

0 commit comments

Comments
 (0)