| @@ 2952-3003 (lines=52) @@ | ||
| 2949 | $this->switchMode( 'inTableMode' ); |
|
| 2950 | return true; |
|
| 2951 | } |
|
| 2952 | private function inTableBodyMode( $token, $value, $attribs = null, $selfclose = false ) { |
|
| 2953 | if ( $token === 'tag' ) { |
|
| 2954 | switch ( $value ) { |
|
| 2955 | case 'tr': |
|
| 2956 | $this->stack->clearToContext( BalanceSets::$tableBodyContextSet ); |
|
| 2957 | $this->stack->insertHTMLElement( $value, $attribs ); |
|
| 2958 | $this->switchMode( 'inRowMode' ); |
|
| 2959 | return true; |
|
| 2960 | case 'th': |
|
| 2961 | case 'td': |
|
| 2962 | $this->inTableBodyMode( 'tag', 'tr', [] ); |
|
| 2963 | $this->insertToken( $token, $value, $attribs, $selfclose ); |
|
| 2964 | return true; |
|
| 2965 | case 'caption': |
|
| 2966 | case 'col': |
|
| 2967 | case 'colgroup': |
|
| 2968 | case 'tbody': |
|
| 2969 | case 'tfoot': |
|
| 2970 | case 'thead': |
|
| 2971 | if ( $this->endSection() ) { |
|
| 2972 | $this->insertToken( $token, $value, $attribs, $selfclose ); |
|
| 2973 | } |
|
| 2974 | return true; |
|
| 2975 | } |
|
| 2976 | } elseif ( $token === 'endtag' ) { |
|
| 2977 | switch ( $value ) { |
|
| 2978 | case 'table': |
|
| 2979 | if ( $this->endSection() ) { |
|
| 2980 | $this->insertToken( $token, $value, $attribs, $selfclose ); |
|
| 2981 | } |
|
| 2982 | return true; |
|
| 2983 | case 'tbody': |
|
| 2984 | case 'tfoot': |
|
| 2985 | case 'thead': |
|
| 2986 | if ( $this->stack->inTableScope( $value ) ) { |
|
| 2987 | $this->endSection(); |
|
| 2988 | } |
|
| 2989 | return true; |
|
| 2990 | # OMITTED: <body> |
|
| 2991 | case 'caption': |
|
| 2992 | case 'col': |
|
| 2993 | case 'colgroup': |
|
| 2994 | # OMITTED: <html> |
|
| 2995 | case 'td': |
|
| 2996 | case 'th': |
|
| 2997 | case 'tr': |
|
| 2998 | return true; // Ignore the token. |
|
| 2999 | } |
|
| 3000 | } |
|
| 3001 | // Anything else: |
|
| 3002 | return $this->inTableMode( $token, $value, $attribs, $selfclose ); |
|
| 3003 | } |
|
| 3004 | ||
| 3005 | // Helper function for inRowMode |
|
| 3006 | private function endRow() { |
|
| @@ 3015-3069 (lines=55) @@ | ||
| 3012 | $this->switchMode( 'inTableBodyMode' ); |
|
| 3013 | return true; |
|
| 3014 | } |
|
| 3015 | private function inRowMode( $token, $value, $attribs = null, $selfclose = false ) { |
|
| 3016 | if ( $token === 'tag' ) { |
|
| 3017 | switch ( $value ) { |
|
| 3018 | case 'th': |
|
| 3019 | case 'td': |
|
| 3020 | $this->stack->clearToContext( BalanceSets::$tableRowContextSet ); |
|
| 3021 | $this->stack->insertHTMLElement( $value, $attribs ); |
|
| 3022 | $this->switchMode( 'inCellMode' ); |
|
| 3023 | $this->afe->insertMarker(); |
|
| 3024 | return true; |
|
| 3025 | case 'caption': |
|
| 3026 | case 'col': |
|
| 3027 | case 'colgroup': |
|
| 3028 | case 'tbody': |
|
| 3029 | case 'tfoot': |
|
| 3030 | case 'thead': |
|
| 3031 | case 'tr': |
|
| 3032 | if ( $this->endRow() ) { |
|
| 3033 | $this->insertToken( $token, $value, $attribs, $selfclose ); |
|
| 3034 | } |
|
| 3035 | return true; |
|
| 3036 | } |
|
| 3037 | } elseif ( $token === 'endtag' ) { |
|
| 3038 | switch ( $value ) { |
|
| 3039 | case 'tr': |
|
| 3040 | $this->endRow(); |
|
| 3041 | return true; |
|
| 3042 | case 'table': |
|
| 3043 | if ( $this->endRow() ) { |
|
| 3044 | $this->insertToken( $token, $value, $attribs, $selfclose ); |
|
| 3045 | } |
|
| 3046 | return true; |
|
| 3047 | case 'tbody': |
|
| 3048 | case 'tfoot': |
|
| 3049 | case 'thead': |
|
| 3050 | if ( |
|
| 3051 | $this->stack->inTableScope( $value ) && |
|
| 3052 | $this->endRow() |
|
| 3053 | ) { |
|
| 3054 | $this->insertToken( $token, $value, $attribs, $selfclose ); |
|
| 3055 | } |
|
| 3056 | return true; |
|
| 3057 | # OMITTED: <body> |
|
| 3058 | case 'caption': |
|
| 3059 | case 'col': |
|
| 3060 | case 'colgroup': |
|
| 3061 | # OMITTED: <html> |
|
| 3062 | case 'td': |
|
| 3063 | case 'th': |
|
| 3064 | return true; // Ignore the token. |
|
| 3065 | } |
|
| 3066 | } |
|
| 3067 | // Anything else: |
|
| 3068 | return $this->inTableMode( $token, $value, $attribs, $selfclose ); |
|
| 3069 | } |
|
| 3070 | ||
| 3071 | // Helper for inCellMode |
|
| 3072 | private function endCell() { |
|