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

Commitbd57c61

Browse files
committed
Get Python tokenizer up to the version of the spec of the end of September.
1 parent7d29315 commitbd57c61

File tree

1 file changed

+75
-5
lines changed

1 file changed

+75
-5
lines changed

‎src/html5lib/tokenizer.py

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def afterDoctypeNameState(self):
955955
matched=False
956956
break
957957
ifmatched:
958-
self.state=self.beforeDoctypePublicIdentifierState
958+
self.state=self.afterDoctypePublicKeywordState
959959
returnTrue
960960
elifdatain (u"s",u"S"):
961961
matched=True
@@ -966,7 +966,7 @@ def afterDoctypeNameState(self):
966966
matched=False
967967
break
968968
ifmatched:
969-
self.state=self.beforeDoctypeSystemIdentifierState
969+
self.state=self.afterDoctypeSystemKeywordState
970970
returnTrue
971971

972972
# All the characters read before the current 'data' will be
@@ -981,6 +981,26 @@ def afterDoctypeNameState(self):
981981
self.state=self.bogusDoctypeState
982982

983983
returnTrue
984+
985+
defafterDoctypePublicKeywordState(self):
986+
data=self.stream.char()
987+
ifdatainspaceCharacters:
988+
self.state=self.beforeDoctypePublicIdentifierState
989+
elifdatain ("'",'"'):
990+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
991+
"unexpected-char-in-doctype"})
992+
self.stream.unget(data)
993+
self.state=self.beforeDoctypePublicIdentifierState
994+
elifdataisEOF:
995+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
996+
"eof-in-doctype"})
997+
self.currentToken["correct"]=False
998+
self.tokenQueue.append(self.currentToken)
999+
self.state=self.dataState
1000+
else:
1001+
self.stream.unget(data)
1002+
self.state=self.beforeDoctypePublicIdentifierState
1003+
returnTrue
9841004

9851005
defbeforeDoctypePublicIdentifierState(self):
9861006
data=self.stream.char()
@@ -1054,17 +1074,47 @@ def doctypePublicIdentifierSingleQuotedState(self):
10541074
defafterDoctypePublicIdentifierState(self):
10551075
data=self.stream.char()
10561076
ifdatainspaceCharacters:
1057-
pass
1058-
elifdata=="\"":
1077+
self.state=self.betweenDoctypePublicAndSystemIdentifiersState
1078+
elifdata==">":
1079+
self.tokenQueue.append(self.currentToken)
1080+
self.state=self.dataState
1081+
elifdata=='"':
1082+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
1083+
"unexpected-char-in-doctype"})
10591084
self.currentToken["systemId"]=u""
10601085
self.state=self.doctypeSystemIdentifierDoubleQuotedState
10611086
elifdata=="'":
1087+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
1088+
"unexpected-char-in-doctype"})
10621089
self.currentToken["systemId"]=u""
10631090
self.state=self.doctypeSystemIdentifierSingleQuotedState
1091+
elifdataisEOF:
1092+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
1093+
"eof-in-doctype"})
1094+
self.currentToken["correct"]=False
1095+
self.tokenQueue.append(self.currentToken)
1096+
self.state=self.dataState
1097+
else:
1098+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
1099+
"unexpected-char-in-doctype"})
1100+
self.currentToken["correct"]=False
1101+
self.state=self.bogusDoctypeState
1102+
returnTrue
1103+
1104+
defbetweenDoctypePublicAndSystemIdentifiersState(self):
1105+
data=self.stream.char()
1106+
ifdatainspaceCharacters:
1107+
pass
10641108
elifdata==">":
10651109
self.tokenQueue.append(self.currentToken)
10661110
self.state=self.dataState
1067-
elifdataisEOF:
1111+
elifdata=='"':
1112+
self.currentToken["systemId"]=u""
1113+
self.state=self.doctypeSystemIdentifierDoubleQuotedState
1114+
elifdata=="'":
1115+
self.currentToken["systemId"]=u""
1116+
self.state=self.doctypeSystemIdentifierSingleQuotedState
1117+
elifdata==EOF:
10681118
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
10691119
"eof-in-doctype"})
10701120
self.currentToken["correct"]=False
@@ -1077,6 +1127,26 @@ def afterDoctypePublicIdentifierState(self):
10771127
self.state=self.bogusDoctypeState
10781128
returnTrue
10791129

1130+
defafterDoctypeSystemKeywordState(self):
1131+
data=self.stream.char()
1132+
ifdatainspaceCharacters:
1133+
self.state=self.beforeDoctypeSystemIdentifierState
1134+
elifdatain ("'",'"'):
1135+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
1136+
"unexpected-char-in-doctype"})
1137+
self.stream.unget(data)
1138+
self.state=self.beforeDoctypeSystemIdentifierState
1139+
elifdataisEOF:
1140+
self.tokenQueue.append({"type":tokenTypes["ParseError"],"data":
1141+
"eof-in-doctype"})
1142+
self.currentToken["correct"]=False
1143+
self.tokenQueue.append(self.currentToken)
1144+
self.state=self.dataState
1145+
else:
1146+
self.stream.unget(data)
1147+
self.state=self.beforeDoctypeSystemIdentifierState
1148+
returnTrue
1149+
10801150
defbeforeDoctypeSystemIdentifierState(self):
10811151
data=self.stream.char()
10821152
ifdatainspaceCharacters:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp