@@ -64,8 +64,9 @@ class HTML5_TreeBuilder {
64
64
65
65
private $ scoping =array ('applet ' ,'button ' ,'caption ' ,'html ' ,'marquee ' ,'object ' ,'table ' ,'td ' ,'th ' ,'svg:foreignObject ' );
66
66
private $ formatting =array ('a ' ,'b ' ,'big ' ,'code ' ,'em ' ,'font ' ,'i ' ,'nobr ' ,'s ' ,'small ' ,'strike ' ,'strong ' ,'tt ' ,'u ' );
67
+ // dl and ds are speculative
67
68
private $ special =array ('address ' ,'area ' ,'article ' ,'aside ' ,'base ' ,'basefont ' ,'bgsound ' ,
68
- 'blockquote ' ,'body ' ,'br ' ,'center ' ,'col ' ,'colgroup ' ,'command ' ,'dd ' ,'details ' ,'dialog ' ,'dir ' ,'div ' ,'dl ' ,
69
+ 'blockquote ' ,'body ' ,'br ' ,'center ' ,'col ' ,'colgroup ' ,'command ' ,'dc ' ,'dd ' ,'details ' ,'dir ' ,'div ' ,'dl ' , ' ds ' ,
69
70
'dt ' ,'embed ' ,'fieldset ' ,'figure ' ,'footer ' ,'form ' ,'frame ' ,'frameset ' ,'h1 ' ,'h2 ' ,'h3 ' ,'h4 ' ,'h5 ' ,
70
71
'h6 ' ,'head ' ,'header ' ,'hgroup ' ,'hr ' ,'iframe ' ,'img ' ,'input ' ,'isindex ' ,'li ' ,'link ' ,
71
72
'listing ' ,'menu ' ,'meta ' ,'nav ' ,'noembed ' ,'noframes ' ,'noscript ' ,'ol ' ,
@@ -752,6 +753,10 @@ public function emitToken($token, $mode = null) {
752
753
// parse error
753
754
break ;
754
755
756
+ case HTML5_Tokenizer::EOF :
757
+ // parse error
758
+ break ;
759
+
755
760
case HTML5_Tokenizer::STARTTAG :
756
761
switch ($ token ['name ' ]) {
757
762
case 'html ' :
@@ -830,7 +835,7 @@ public function emitToken($token, $mode = null) {
830
835
// in spec, there is a diversion here
831
836
832
837
case 'address ' :case 'article ' :case 'aside ' :case 'blockquote ' :
833
- case 'center ' :case 'datagrid ' :case 'details ' :case 'dialog ' : case ' dir ' :
838
+ case 'center ' :case 'datagrid ' :case 'details ' :case 'dir ' :
834
839
case 'div ' :case 'dl ' :case 'fieldset ' :case 'figure ' :case 'footer ' :
835
840
case 'header ' :case 'hgroup ' :case 'menu ' :case 'nav ' :
836
841
case 'ol ' :case 'p ' :case 'section ' :case 'ul ' :
@@ -921,7 +926,7 @@ public function emitToken($token, $mode = null) {
921
926
break ;
922
927
923
928
// condensed specification
924
- case 'li ' :case 'dd ' :case 'dt ' :
929
+ case 'li ' :case 'dc ' : case ' dd ' : case ' ds ' :case 'dt ' :
925
930
/* 1. Set the frameset-ok flag to "not ok". */
926
931
$ this ->flag_frameset_ok =false ;
927
932
@@ -937,12 +942,12 @@ public function emitToken($token, $mode = null) {
937
942
/* 3. If node is an li element, then act as if an end
938
943
* tag with the tag name "li" had been seen, then jump
939
944
* to the last step. */
940
- // for case 'dd ': case 'dt':
941
- /* If node is add or dt element, then act as if an end
945
+ // for case 'dc': case 'dd': case 'ds ': case 'dt':
946
+ /* If node is adc, dd, ds or dt element, then act as if an end
942
947
* tag with the same tag name as node had been seen, then
943
948
* jump to the last step. */
944
949
if (($ token ['name ' ] ==='li ' &&$ node ->tagName ==='li ' ) ||
945
- ($ token ['name ' ] !=='li ' && ($ node ->tagName === 'dd ' ||$ node ->tagName ==='dt ' ))) {// limited conditional
950
+ ($ token ['name ' ] !=='li ' && ($ node ->tagName ==' dc ' || $ node -> tagName === 'dd ' || $ node -> tagName == ' ds ' ||$ node ->tagName ==='dt ' ))) {// limited conditional
946
951
$ this ->emitToken (array (
947
952
'type ' => HTML5_Tokenizer::ENDTAG ,
948
953
'name ' =>$ node ->tagName ,
@@ -1463,20 +1468,21 @@ public function emitToken($token, $mode = null) {
1463
1468
switch ($ token ['name ' ]) {
1464
1469
/* An end tag with the tag name "body" */
1465
1470
case 'body ' :
1466
- /* If thesecond element in the stack of open elementsis
1467
- not a body element, this is a parse error. Ignore thetoken.
1468
- (innerHTML case) */
1469
- if (count ( $ this ->stack ) < 2 || $ this -> stack [ 1 ]-> tagName !== 'body ' ) {
1471
+ /* If the stack of open elementsdoes not have a body
1472
+ * element in scope , this is a parse error; ignore the
1473
+ * token. */
1474
+ if (! $ this ->elementInScope ( 'body ' ) ) {
1470
1475
$ this ->ignored =true ;
1471
1476
1472
- /* Otherwise, if there is a node in the stack of open
1473
- * elements that is not either a dd element, a dt
1474
- * element, an li element, an optgroup element, an
1475
- * option element, a p element, an rp element, an rt
1476
- * element, a tbody element, a td element, a tfoot
1477
- * element, a th element, a thead element, a tr element,
1478
- * the body element, or the html element, then this is a
1479
- * parse error. */
1477
+ /* Otherwise, if there is a node in the stack of open
1478
+ * elements that is not either a dc element, a dd element,
1479
+ * a ds element, a dt element, an li element, an optgroup
1480
+ * element, an option element, a p element, an rp element,
1481
+ * an rt element, a tbody element, a td element, a tfoot
1482
+ * element, a th element, a thead element, a tr element,
1483
+ * the body element, or the html element, then this is a
1484
+ * parse error.
1485
+ */
1480
1486
}else {
1481
1487
// XERROR: implement this check for parse error
1482
1488
}
@@ -1500,7 +1506,7 @@ public function emitToken($token, $mode = null) {
1500
1506
1501
1507
case 'address ' :case 'article ' :case 'aside ' :case 'blockquote ' :
1502
1508
case 'center ' :case 'datagrid ' :case 'details ' :case 'dir ' :
1503
- case 'div ' :case 'dl ' :case 'fieldset ' :case 'figure ' : case ' footer ' :
1509
+ case 'div ' :case 'dl ' :case 'fieldset ' :case 'footer ' :
1504
1510
case 'header ' :case 'hgroup ' :case 'listing ' :case 'menu ' :
1505
1511
case 'nav ' :case 'ol ' :case 'pre ' :case 'section ' :case 'ul ' :
1506
1512
/* If the stack of open elements has an element in scope
@@ -1603,8 +1609,8 @@ public function emitToken($token, $mode = null) {
1603
1609
}
1604
1610
break ;
1605
1611
1606
- /* An end tag whose tag name is "dd", "dt ",or "li " */
1607
- case 'dd ' :case 'dt ' :
1612
+ /* An end tag whose tag name is "dc", " dd", "ds ","dt " */
1613
+ case 'dc ' : case ' dd ' : case ' ds ' :case 'dt ' :
1608
1614
if ($ this ->elementInScope ($ token ['name ' ])) {
1609
1615
$ this ->generateImpliedEndTags (array ($ token ['name ' ]));
1610
1616
@@ -2863,7 +2869,7 @@ public function emitToken($token, $mode = null) {
2863
2869
}elseif ($ token ['type ' ] === HTML5_Tokenizer::EOF || (
2864
2870
$ token ['type ' ] === HTML5_Tokenizer::STARTTAG &&
2865
2871
(in_array ($ token ['name ' ],array ('b ' ,"big " ,"blockquote " ,"body " ,"br " ,
2866
- "center " ,"code " ,"dd " ,"div " ,"dl " ,"dt " ,"em " ,"embed " ,"h1 " ,"h2 " ,
2872
+ "center " ,"code " ,"dc " , " dd " ,"div " ,"dl " , " ds " ,"dt " ,"em " ,"embed " ,"h1 " ,"h2 " ,
2867
2873
"h3 " ,"h4 " ,"h5 " ,"h6 " ,"head " ,"hr " ,"i " ,"img " ,"li " ,"listing " ,
2868
2874
"menu " ,"meta " ,"nobr " ,"ol " ,"p " ,"pre " ,"ruby " ,"s " ,"small " ,
2869
2875
"span " ,"strong " ,"strike " ,"sub " ,"sup " ,"table " ,"tt " ,"u " ,"ul " ,
@@ -3341,13 +3347,13 @@ private function clearTheActiveFormattingElementsUpToTheLastMarker() {
3341
3347
}
3342
3348
3343
3349
private function generateImpliedEndTags ($ exclude =array ()) {
3344
- /* When the steps below require the UA to generate implied end tags,
3345
- then,if the current node is add element, adt element,an li element,
3346
- a p element, atd element,a th element,or a tr element,the UA must
3347
- act as if an end tag with the respective tag name had been seen and
3348
- then generate implied end tags again . */
3350
+ /* When the steps below require the UA to generate implied end tags,
3351
+ * then,while the current node is adc element, add element,a ds
3352
+ * element, adt element,an li element,an option element,an optgroup
3353
+ * element, a p element, an rp element, or an rt element, the UA must
3354
+ * pop the current node off the stack of open elements . */
3349
3355
$ node =end ($ this ->stack );
3350
- $ elements =array_diff (array ('dd ' ,'dt ' ,'li ' ,'p ' ,'td ' ,'th ' ,'tr ' ),$ exclude );
3356
+ $ elements =array_diff (array ('dc ' , ' dd ' , ' ds ' ,'dt ' ,'li ' ,'p ' ,'td ' ,'th ' ,'tr ' ),$ exclude );
3351
3357
3352
3358
while (in_array (end ($ this ->stack )->tagName ,$ elements )) {
3353
3359
array_pop ($ this ->stack );