@@ -644,10 +644,12 @@ private function step_in_body() {
644644 case '+MAIN ' :
645645 case '+MENU ' :
646646 case '+NAV ' :
647+ case '+OL ' :
647648 case '+P ' :
648649 case '+SEARCH ' :
649650 case '+SECTION ' :
650651 case '+SUMMARY ' :
652+ case '+UL ' :
651653 if ( $ this ->state ->stack_of_open_elements ->has_p_in_button_scope () ) {
652654 $ this ->close_a_p_element ();
653655 }
@@ -681,9 +683,11 @@ private function step_in_body() {
681683 case '-MAIN ' :
682684 case '-MENU ' :
683685 case '-NAV ' :
686+ case '-OL ' :
684687 case '-SEARCH ' :
685688 case '-SECTION ' :
686689 case '-SUMMARY ' :
690+ case '-UL ' :
687691 if ( ! $ this ->state ->stack_of_open_elements ->has_element_in_scope ( $ tag_name ) ) {
688692 // @TODO: Report parse error.
689693 // Ignore the token.
@@ -733,7 +737,11 @@ private function step_in_body() {
733737 case '-H4 ' :
734738 case '-H5 ' :
735739 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+ ) {
737745 /*
738746 * This is a parse error; ignore the token.
739747 *
@@ -751,6 +759,92 @@ private function step_in_body() {
751759 $ this ->state ->stack_of_open_elements ->pop_until ( '(internal: H1 through H6 - do not use) ' );
752760 return true ;
753761
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+
754848 /*
755849 * > An end tag whose tag name is "p"
756850 */
@@ -1128,6 +1222,9 @@ private function close_a_p_element() {
11281222 */
11291223 private function generate_implied_end_tags ( $ except_for_this_element = null ) {
11301224 $ elements_with_implied_end_tags = array (
1225+ 'DD ' ,
1226+ 'DT ' ,
1227+ 'LI ' ,
11311228 'P ' ,
11321229 );
11331230
@@ -1153,6 +1250,9 @@ private function generate_implied_end_tags( $except_for_this_element = null ) {
11531250 */
11541251 private function generate_implied_end_tags_thoroughly () {
11551252 $ elements_with_implied_end_tags = array (
1253+ 'DD ' ,
1254+ 'DT ' ,
1255+ 'LI ' ,
11561256 'P ' ,
11571257 );
11581258
0 commit comments