@@ -120,8 +120,8 @@ public function data_external_html5lib_tests() {
120120 * @return string|null Tree structure of parsed HTML, if supported, else null.
121121 */
122122 public static function build_html5_treelike_string ( $ fragment_context , $ html ) {
123- $ p = WP_HTML_Processor::create_fragment ( $ html , "< {$ fragment_context }> " );
124- if ( null === $ p ) {
123+ $ processor = WP_HTML_Processor::create_fragment ( $ html , "< {$ fragment_context }> " );
124+ if ( null === $ processor ) {
125125 return null ;
126126 }
127127
@@ -131,34 +131,34 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
131131 $ indent_level = 2 ;
132132 $ indent = ' ' ;
133133
134- while ( $ p ->next_token () ) {
135- if ( $ p ->get_last_error () !== null ) {
134+ while ( $ processor ->next_token () ) {
135+ if ( $ processor ->get_last_error () !== null ) {
136136 return null ;
137137 }
138138
139- switch ( $ p ->get_token_type () ) {
139+ switch ( $ processor ->get_token_type () ) {
140140 case '#tag ' :
141- $ tag_name = strtolower ( $ p ->get_tag () );
141+ $ tag_name = strtolower ( $ processor ->get_tag () );
142142
143- if ( $ p ->is_tag_closer () ) {
143+ if ( $ processor ->is_tag_closer () ) {
144144 --$ indent_level ;
145145 break ;
146146 }
147147
148- $ tag_indent = count ( $ p ->get_breadcrumbs () ) - 1 ;
148+ $ tag_indent = count ( $ processor ->get_breadcrumbs () ) - 1 ;
149149
150150 if ( ! WP_HTML_Processor::is_void ( $ tag_name ) ) {
151151 $ indent_level = $ tag_indent + 1 ;
152152 }
153153
154154 $ output .= str_repeat ( $ indent , $ tag_indent ) . "< {$ tag_name }> \n" ;
155155
156- $ attribute_names = $ p ->get_attribute_names_with_prefix ( '' );
156+ $ attribute_names = $ processor ->get_attribute_names_with_prefix ( '' );
157157 if ( $ attribute_names ) {
158158 sort ( $ attribute_names , SORT_STRING );
159159
160160 foreach ( $ attribute_names as $ attribute_name ) {
161- $ val = $ p ->get_attribute ( $ attribute_name );
161+ $ val = $ processor ->get_attribute ( $ attribute_name );
162162 /*
163163 * Attributes with no value are `true` with the HTML API,
164164 * We map use the empty string value in the tree structure.
@@ -173,7 +173,7 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
173173 break ;
174174
175175 case '#text ' :
176- $ output .= str_repeat ( $ indent , $ indent_level ) . "\"{$ p ->get_modifiable_text ()}\"\n" ;
176+ $ output .= str_repeat ( $ indent , $ indent_level ) . "\"{$ processor ->get_modifiable_text ()}\"\n" ;
177177 break ;
178178
179179 case '#cdata-section ' :
@@ -184,7 +184,7 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
184184
185185 case '#comment ' :
186186 // Comments must be "<" then "!-- " then the data then " -->".
187- $ output .= str_repeat ( $ indent , $ indent_level ) . "<!-- {$ p ->get_modifiable_text ()} --> \n" ;
187+ $ output .= str_repeat ( $ indent , $ indent_level ) . "<!-- {$ processor ->get_modifiable_text ()} --> \n" ;
188188 break ;
189189
190190 case '#doctype ' :
@@ -198,11 +198,11 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
198198 }
199199 }
200200
201- if ( WP_HTML_Processor::ERROR_UNSUPPORTED === $ p ->get_last_error () ) {
201+ if ( WP_HTML_Processor::ERROR_UNSUPPORTED === $ processor ->get_last_error () ) {
202202 return null ;
203203 }
204204
205- if ( $ p ->paused_at_incomplete_token () ) {
205+ if ( $ processor ->paused_at_incomplete_token () ) {
206206 return null ;
207207 }
208208
0 commit comments