@@ -644,10 +644,12 @@ private function step_in_body() {
644
644
case '+MAIN ' :
645
645
case '+MENU ' :
646
646
case '+NAV ' :
647
+ case '+OL ' :
647
648
case '+P ' :
648
649
case '+SEARCH ' :
649
650
case '+SECTION ' :
650
651
case '+SUMMARY ' :
652
+ case '+UL ' :
651
653
if ( $ this ->state ->stack_of_open_elements ->has_p_in_button_scope () ) {
652
654
$ this ->close_a_p_element ();
653
655
}
@@ -681,9 +683,11 @@ private function step_in_body() {
681
683
case '-MAIN ' :
682
684
case '-MENU ' :
683
685
case '-NAV ' :
686
+ case '-OL ' :
684
687
case '-SEARCH ' :
685
688
case '-SECTION ' :
686
689
case '-SUMMARY ' :
690
+ case '-UL ' :
687
691
if ( ! $ this ->state ->stack_of_open_elements ->has_element_in_scope ( $ tag_name ) ) {
688
692
// @TODO: Report parse error.
689
693
// Ignore the token.
@@ -733,7 +737,11 @@ private function step_in_body() {
733
737
case '-H4 ' :
734
738
case '-H5 ' :
735
739
case '-H6 ' :
736
- if ( ! $ this ->state ->stack_of_open_elements ->has_element_in_scope ( '(internal: H1 through H6 - do not use) ' ) ) {
740
+ if (
741
+ ! $ this ->state ->stack_of_open_elements ->has_element_in_scope (
742
+ '(internal: H1 through H6 - do not use) '
743
+ )
744
+ ) {
737
745
/*
738
746
* This is a parse error; ignore the token.
739
747
*
@@ -751,6 +759,92 @@ private function step_in_body() {
751
759
$ this ->state ->stack_of_open_elements ->pop_until ( '(internal: H1 through H6 - do not use) ' );
752
760
return true ;
753
761
762
+ /*
763
+ * > A start tag whose tag name is "li"
764
+ * > A start tag whose tag name is one of: "dd", "dt"
765
+ */
766
+ case '+DD ' :
767
+ case '+DT ' :
768
+ case '+LI ' :
769
+ $ this ->state ->frameset_ok = false ;
770
+ $ node = $ this ->state ->stack_of_open_elements ->current_node ();
771
+
772
+ in_body_list_loop:
773
+ if ( $ tag_name === $ node ->node_name ) {
774
+ $ this ->generate_implied_end_tags ();
775
+ if ( $ tag_name !== $ this ->state ->stack_of_open_elements ->current_node ()->node_name ) {
776
+ // @TODO: Indicate a parse error once it's possible. This error does not impact the logic here.
777
+ }
778
+
779
+ $ this ->state ->stack_of_open_elements ->pop_until ( $ tag_name );
780
+ goto in_body_list_done;
781
+ }
782
+
783
+ if (
784
+ 'ADDRESS ' !== $ node ->node_name &&
785
+ 'DIV ' !== $ node ->node_name &&
786
+ 'P ' !== $ node ->node_name &&
787
+ $ this ->is_special ( $ node ->node_name )
788
+ ) {
789
+ /*
790
+ * > If node is in the special category, but is not an address, div,
791
+ * > or p element, then jump to the step labeled done below.
792
+ */
793
+ goto in_body_list_done;
794
+ } else {
795
+ /*
796
+ * > Otherwise, set node to the previous entry in the stack of open elements
797
+ * > and return to the step labeled loop.
798
+ */
799
+ foreach ( $ this ->state ->stack_of_open_elements ->walk_up ( $ node ) as $ item ) {
800
+ $ node = $ item ;
801
+ break ;
802
+ }
803
+ goto in_body_list_loop;
804
+ }
805
+
806
+ in_body_list_done:
807
+ if ( $ this ->state ->stack_of_open_elements ->has_p_in_button_scope () ) {
808
+ $ this ->close_a_p_element ();
809
+ }
810
+
811
+ $ this ->insert_html_element ( $ this ->state ->current_token );
812
+ return true ;
813
+
814
+ /*
815
+ * > An end tag whose tag name is "li"
816
+ * > An end tag whose tag name is one of: "dd", "dt"
817
+ */
818
+ case '-DD ' :
819
+ case '-DT ' :
820
+ case '-LI ' :
821
+ if (
822
+ (
823
+ 'LI ' === $ tag_name &&
824
+ ! $ this ->state ->stack_of_open_elements ->has_element_in_list_item_scope ( 'LI ' )
825
+ ) ||
826
+ (
827
+ 'LI ' !== $ tag_name &&
828
+ ! $ this ->state ->stack_of_open_elements ->has_element_in_scope ( $ tag_name )
829
+ )
830
+ ) {
831
+ /*
832
+ * This is a parse error, ignore the token.
833
+ *
834
+ * @TODO: Indicate a parse error once it's possible.
835
+ */
836
+ return $ this ->step ();
837
+ }
838
+
839
+ $ this ->generate_implied_end_tags ( $ tag_name );
840
+
841
+ if ( $ tag_name !== $ this ->state ->stack_of_open_elements ->current_node ()->node_name ) {
842
+ // @TODO: Indicate a parse error once it's possible. This error does not impact the logic here.
843
+ }
844
+
845
+ $ this ->state ->stack_of_open_elements ->pop_until ( $ tag_name );
846
+ return true ;
847
+
754
848
/*
755
849
* > An end tag whose tag name is "p"
756
850
*/
@@ -1128,6 +1222,9 @@ private function close_a_p_element() {
1128
1222
*/
1129
1223
private function generate_implied_end_tags ( $ except_for_this_element = null ) {
1130
1224
$ elements_with_implied_end_tags = array (
1225
+ 'DD ' ,
1226
+ 'DT ' ,
1227
+ 'LI ' ,
1131
1228
'P ' ,
1132
1229
);
1133
1230
@@ -1153,6 +1250,9 @@ private function generate_implied_end_tags( $except_for_this_element = null ) {
1153
1250
*/
1154
1251
private function generate_implied_end_tags_thoroughly () {
1155
1252
$ elements_with_implied_end_tags = array (
1253
+ 'DD ' ,
1254
+ 'DT ' ,
1255
+ 'LI ' ,
1156
1256
'P ' ,
1157
1257
);
1158
1258
0 commit comments