Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite67ed4f

Browse files
committed
Implemented "compatMode"
--HG--extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401119
1 parentc8140dd commite67ed4f

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

‎src/html5lib/html5parser.py‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def __init__(self, strict = False, tree=simpletree.TreeBuilder,
5353
self.tokenizer_class=tokenizer
5454
self.errors= []
5555

56-
# "quirks" / "almost-standards" / "standards"
57-
self.quirksMode="standards"
56+
# "quirks" / "limited-quirks" / "no-quirks"
57+
self.compatMode="no-quirks"
5858

5959
self.phases= {
6060
"initial":InitialPhase(self,self.tree),
@@ -304,6 +304,7 @@ class InitialPhase(Phase):
304304
# this.
305305
defprocessEOF(self):
306306
self.parser.parseError("expected-doctype-but-got-eof")
307+
self.compatMode="quirks"
307308
self.parser.phase=self.parser.phases["beforeHtml"]
308309
self.parser.phase.processEOF()
309310

@@ -323,11 +324,8 @@ def processDoctype(self, name, publicId, systemId, correct):
323324
ifpublicId!="":
324325
publicId=publicId.translate(asciiUpper2Lower)
325326

326-
ifnameLower!="html":
327-
# XXX quirks mode
328-
pass
329-
else:
330-
ifpublicIdin\
327+
ifnotcorrectornameLower!="html"\
328+
orpublicIdin\
331329
("+//silmaril//dtd html pro v0r11 19970101//en",
332330
"-//advasoft ltd//dtd html 3.0 aswedit + extensions//en",
333331
"-//as//dtd html 3.0 aswedit + extensions//en",
@@ -397,13 +395,19 @@ def processDoctype(self, name, publicId, systemId, correct):
397395
"-//webtechs//dtd mozilla html//en",
398396
"-/w3c/dtd html 4.0 transitional/en",
399397
"html")\
400-
or (publicIdin\
398+
or (publicIdin\
401399
("-//w3c//dtd html 4.01 frameset//EN",
402400
"-//w3c//dtd html 4.01 transitional//EN")andsystemId==None)\
403-
or (systemId!=Noneand\
401+
or (systemId!=Noneand\
404402
systemId=="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"):
405-
#XXX quirks mode
406-
pass
403+
self.compatMode="quirks"
404+
elifpublicIdin\
405+
("-//w3c//dtd xhtml 1.0 frameset//EN",
406+
"-//w3c//dtd xhtml 1.0 transitional//EN")\
407+
or (publicIdin\
408+
("-//w3c//dtd html 4.01 frameset//EN",
409+
"-//w3c//dtd html 4.01 transitional//EN")andsystemId==None):
410+
self.compatMode="limited-quirks"
407411

408412
self.parser.phase=self.parser.phases["beforeHtml"]
409413

@@ -412,18 +416,21 @@ def processSpaceCharacters(self, data):
412416

413417
defprocessCharacters(self,data):
414418
self.parser.parseError("expected-doctype-but-got-chars")
419+
self.compatMode="quirks"
415420
self.parser.phase=self.parser.phases["beforeHtml"]
416421
self.parser.phase.processCharacters(data)
417422

418423
defprocessStartTag(self,name,attributes):
419424
self.parser.parseError("expected-doctype-but-got-start-tag",
420425
{"name":name})
426+
self.compatMode="quirks"
421427
self.parser.phase=self.parser.phases["beforeHtml"]
422428
self.parser.phase.processStartTag(name,attributes)
423429

424430
defprocessEndTag(self,name):
425431
self.parser.parseError("expected-doctype-but-got-end-tag",
426432
{"name":name})
433+
self.compatMode="quirks"
427434
self.parser.phase=self.parser.phases["beforeHtml"]
428435
self.parser.phase.processEndTag(name)
429436

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp