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

Commit54bb5ec

Browse files
committed
Take into account r1178 of HTML5's draft in the Python implementation (note that previous changes to the spec aren't yet implemented, this changeset doesn't thus make the implementation conforming to r1178, just to r1177-r1178 changes).
Adds tests for the "p" optional end tag, but not for the 'rt' and 'rp', neither for the parser changes (at least, they don't break existing tests)--HG--extra : convert_revision : svn%3Aacbfec75-9323-0410-a652-858a13e371e0/trunk%401182
1 parent2530b06 commit54bb5ec

File tree

3 files changed

+50
-18
lines changed

3 files changed

+50
-18
lines changed

‎src/html5lib/constants.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@
292292
specialElements=frozenset((
293293
"address",
294294
"area",
295+
"article",
296+
"aside",
295297
"base",
296298
"basefont",
297299
"bgsound",
@@ -301,13 +303,20 @@
301303
"center",
302304
"col",
303305
"colgroup",
306+
"command",
307+
"datagrid",
304308
"dd",
309+
"details",
310+
"dialog",
305311
"dir",
306312
"div",
307313
"dl",
308314
"dt",
309315
"embed",
316+
"event-source",
310317
"fieldset",
318+
"figure",
319+
"footer",
311320
"form",
312321
"frame",
313322
"frameset",
@@ -318,9 +327,12 @@
318327
"h5",
319328
"h6",
320329
"head",
330+
"header",
321331
"hr",
322332
"iframe",
323-
"image",
333+
# Note that image is commented out in the spec as "this isn't an
334+
# element that can end up on the stack, so it doesn't matter"
335+
"image",
324336
"img",
325337
"input",
326338
"isindex",
@@ -329,6 +341,7 @@
329341
"listing",
330342
"menu",
331343
"meta",
344+
"nav",
332345
"noembed",
333346
"noframes",
334347
"noscript",
@@ -340,6 +353,7 @@
340353
"plaintext",
341354
"pre",
342355
"script",
356+
"section",
343357
"select",
344358
"spacer",
345359
"style",
@@ -389,9 +403,10 @@
389403
"h6"
390404
)
391405

392-
# XXX What about event-source and command?
393406
voidElements=frozenset((
394407
"base",
408+
"command",
409+
"event-source",
395410
"link",
396411
"meta",
397412
"hr",
@@ -401,7 +416,8 @@
401416
"param",
402417
"area",
403418
"col",
404-
"input"
419+
"input",
420+
"source"
405421
))
406422

407423
cdataElements=frozenset(('title','textarea'))

‎src/html5lib/filters/optionaltags.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,28 @@ def is_optional_end(self, tagname, next):
112112
returnFalse
113113
eliftagname=='p':
114114
# A p element's end tag may be omitted if the p element is
115-
# immediately followed by an address, blockquote, dl, fieldset,
116-
# form, h1, h2, h3, h4, h5, h6, hr, menu, ol, p, pre, table,
117-
# or ul element, or if there is no more content in the parent
118-
# element.
115+
# immediately followed by an address, article, aside,
116+
# blockquote, datagrid, dialog, dir, div, dl, fieldset,
117+
# footer, form, h1, h2, h3, h4, h5, h6, header, hr, menu,
118+
# nav, ol, p, pre, section, table, or ul, element, or if
119+
# there is no more content in the parent element.
120+
iftype=="StartTag":
121+
returnnext["name"]in ('address','article','aside', \
122+
'blockquote','datagrid','dialog','dir','div', \
123+
'dl','fieldset','footer','form','h1','h2','h3', \
124+
'h4','h5','h6','header','hr','menu','nav','ol', \
125+
'p','pre','section','table','ul')
126+
else:
127+
returntype=="EndTag"ortypeisNone
128+
eliftagnamein ('rt','rp'):
129+
# An rt element's end tag may be omitted if the rt element is
130+
# immediately followed by an rt or rp element, or if there is
131+
# no more content in the parent element.
132+
# An rp element's end tag may be omitted if the rp element is
133+
# immediately followed by an rt or rp element, or if there is
134+
# no more content in the parent element.
119135
iftype=="StartTag":
120-
returnnext["name"]in ('address','blockquote', \
121-
'dl','fieldset','form','h1','h2','h3','h4','h5', \
122-
'h6','hr','menu','ol','p','pre','table','ul')
136+
returnnext["name"]in ('rt','rp')
123137
else:
124138
returntype=="EndTag"ortypeisNone
125139
eliftagname=='colgroup':

‎src/html5lib/html5parser.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,10 @@ def __init__(self, parser, tree):
709709
(("base","link","meta","script","style","title"),
710710
self.startTagProcessInHead),
711711
("body",self.startTagBody),
712-
(("address","blockquote","center","dir","div","dl",
713-
"fieldset","listing","menu","ol","p","pre","ul"),
712+
(("address","article","aside","blockquote","center","datagrid",
713+
"details","dialog","dir","div","dl","fieldset","figure",
714+
"footer","h1","h2","h3","h4","h5","h6","header","listing",
715+
"menu","nav","ol","p","pre","section","ul"),
714716
self.startTagCloseP),
715717
("form",self.startTagForm),
716718
(("li","dd","dt"),self.startTagListItem),
@@ -736,17 +738,18 @@ def __init__(self, parser, tree):
736738
(("caption","col","colgroup","frame","frameset","head",
737739
"option","optgroup","tbody","td","tfoot","th","thead",
738740
"tr"),self.startTagMisplaced),
739-
(("event-source","section","nav","article","aside","header",
740-
"footer","datagrid","command"),self.startTagNew)
741+
(("event-source","command"),self.startTagNew)
741742
])
742743
self.startTagHandler.default=self.startTagOther
743744

744745
self.endTagHandler=utils.MethodDispatcher([
745746
("p",self.endTagP),
746747
("body",self.endTagBody),
747748
("html",self.endTagHtml),
748-
(("address","blockquote","center","div","dl","fieldset",
749-
"listing","menu","ol","pre","ul"),self.endTagBlock),
749+
(("address","article","aside","blockquote","center","datagrid",
750+
"details","dialog","dir","div","dl","fieldset","figure",
751+
"footer","header","listing","menu","nav","ol","pre","section",
752+
"ul"),self.endTagBlock),
750753
("form",self.endTagForm),
751754
(("dd","dt","li"),self.endTagListItem),
752755
(headingElements,self.endTagHeading),
@@ -762,8 +765,7 @@ def __init__(self, parser, tree):
762765
self.endTagNone),
763766
(("noframes","noscript","noembed","textarea","xmp","iframe"),
764767
self.endTagCdataTextAreaXmp),
765-
(("event-source","section","nav","article","aside","header",
766-
"footer","datagrid","command"),self.endTagNew)
768+
(("event-source","command"),self.endTagNew)
767769
])
768770
self.endTagHandler.default=self.endTagOther
769771

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp