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

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎src/html5lib/html5parser.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ def any(iterable):
1414
ifelement:
1515
returnTrue
1616
returnFalse
17+
18+
try:
19+
"abc".startswith(("a","b"))
20+
defstartswithany(str,prefixes):
21+
returnstr.startswith(prefixes)
22+
except:
23+
# Python 2.4 doesn't accept a tuple as argument to string startswith
24+
defstartswithany(str,prefixes):
25+
forprefixinprefixes:
26+
ifstr.startswith(prefix):
27+
returnTrue
28+
returnFalse
1729

1830
importsys
1931

@@ -485,7 +497,7 @@ def processDoctype(self, token):
485497
publicId=publicId.translate(asciiUpper2Lower)
486498

487499
if (notcorrectortoken["name"]!="html"
488-
orpublicId.startswith(
500+
orstartswithany(publicId,
489501
("+//silmaril//dtd html pro v0r11 19970101//",
490502
"-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
491503
"-//as//dtd html 3.0 aswedit + extensions//",
@@ -545,16 +557,16 @@ def processDoctype(self, token):
545557
("-//w3o//dtd w3 html strict 3.0//en//",
546558
"-/w3c/dtd html 4.0 transitional/en",
547559
"html")
548-
orpublicId.startswith(
560+
orstartswithany(publicId,
549561
("-//w3c//dtd html 4.01 frameset//",
550562
"-//w3c//dtd html 4.01 transitional//"))and
551563
systemId==None
552564
orsystemIdandsystemId.lower()=="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"):
553565
self.parser.compatMode="quirks"
554-
elif (publicId.startswith(
566+
elif (startswithany(publicId,
555567
("-//w3c//dtd xhtml 1.0 frameset//",
556568
"-//w3c//dtd xhtml 1.0 transitional//"))
557-
orpublicId.startswith(
569+
orstartswithany(publicId,
558570
("-//w3c//dtd html 4.01 frameset//",
559571
"-//w3c//dtd html 4.01 transitional//"))and
560572
systemId!=None):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp