@@ -16,10 +16,10 @@ function get_supports(): array {
16
16
$ html_processor_state_rc = new ReflectionClass ( WP_HTML_Processor_State::class );
17
17
18
18
return array (
19
- 'is_virtual ' => $ html_processor_rc ->hasMethod ( 'is_virtual ' ),
19
+ 'is_virtual ' => $ html_processor_rc ->hasMethod ( 'is_virtual ' ),
20
20
'full_parser ' => method_exists ( WP_HTML_Processor::class, 'create_full_parser ' ),
21
21
'quirks_mode ' => $ html_processor_state_rc ->hasProperty ( 'document_mode ' ),
22
- 'doctype ' => method_exists ( WP_HTML_Processor::class, 'get_doctype_info ' ),
22
+ 'doctype ' => method_exists ( WP_HTML_Processor::class, 'get_doctype_info ' ),
23
23
);
24
24
}
25
25
@@ -98,32 +98,32 @@ function get_tree( string $html, array $options ): array {
98
98
}
99
99
100
100
$ tree = array (
101
- 'nodeType ' => NODE_TYPE_DOCUMENT ,
102
- 'nodeName ' => '#document ' ,
101
+ 'nodeType ' => NODE_TYPE_DOCUMENT ,
102
+ 'nodeName ' => '#document ' ,
103
103
'childNodes ' => array (),
104
104
);
105
105
106
106
$ cursor = array ( 0 );
107
107
if ( ! $ use_full_parser ) {
108
108
$ tree ['childNodes ' ][] = array (
109
- 'nodeType ' => NODE_TYPE_DOCUMENT_TYPE ,
110
- 'nodeName ' => $ doctype_value ,
109
+ 'nodeType ' => NODE_TYPE_DOCUMENT_TYPE ,
110
+ 'nodeName ' => $ doctype_value ,
111
111
'nodeValue ' => '' ,
112
112
);
113
113
$ tree ['childNodes ' ][] = array (
114
- 'nodeType ' => NODE_TYPE_ELEMENT ,
115
- 'nodeName ' => 'HTML ' ,
114
+ 'nodeType ' => NODE_TYPE_ELEMENT ,
115
+ 'nodeName ' => 'HTML ' ,
116
116
'attributes ' => array (),
117
117
'childNodes ' => array (
118
118
array (
119
- 'nodeType ' => NODE_TYPE_ELEMENT ,
120
- 'nodeName ' => 'HEAD ' ,
119
+ 'nodeType ' => NODE_TYPE_ELEMENT ,
120
+ 'nodeName ' => 'HEAD ' ,
121
121
'attributes ' => array (),
122
122
'childNodes ' => array (),
123
123
),
124
124
array (
125
- 'nodeType ' => NODE_TYPE_ELEMENT ,
126
- 'nodeName ' => 'BODY ' ,
125
+ 'nodeType ' => NODE_TYPE_ELEMENT ,
126
+ 'nodeName ' => 'BODY ' ,
127
127
'attributes ' => array (),
128
128
'childNodes ' => array (),
129
129
),
@@ -168,10 +168,10 @@ function get_tree( string $html, array $options ): array {
168
168
$ current ['childNodes ' ][] = array (
169
169
'nodeType ' => NODE_TYPE_DOCUMENT_TYPE ,
170
170
'nodeName ' => $ doctype_name ,
171
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
172
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
173
- '_bc ' => $ processor ->get_breadcrumbs (),
174
- '_depth ' => $ get_current_depth (),
171
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
172
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
173
+ '_bc ' => $ processor ->get_breadcrumbs (),
174
+ '_depth ' => $ get_current_depth (),
175
175
);
176
176
}
177
177
break ;
@@ -193,40 +193,40 @@ function get_tree( string $html, array $options ): array {
193
193
$ val = '' ;
194
194
}
195
195
$ attributes [] = array (
196
- 'nodeType ' => NODE_TYPE_ATTRIBUTE ,
196
+ 'nodeType ' => NODE_TYPE_ATTRIBUTE ,
197
197
'specified ' => true ,
198
- 'nodeName ' => $ get_attribute_name ( $ attribute_name ),
198
+ 'nodeName ' => $ get_attribute_name ( $ attribute_name ),
199
199
'nodeValue ' => $ val ,
200
200
);
201
201
}
202
202
}
203
203
204
204
$ self = array (
205
- 'nodeType ' => NODE_TYPE_ELEMENT ,
206
- 'nodeName ' => $ tag_name ,
205
+ 'nodeType ' => NODE_TYPE_ELEMENT ,
206
+ 'nodeName ' => $ tag_name ,
207
207
'attributes ' => $ attributes ,
208
208
'childNodes ' => array (),
209
- '_closer ' => (bool ) $ processor ->is_tag_closer (),
210
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
211
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
212
- '_bc ' => $ processor ->get_breadcrumbs (),
213
- '_virtual ' => $ is_virtual (),
214
- '_depth ' => $ get_current_depth (),
209
+ '_closer ' => (bool ) $ processor ->is_tag_closer (),
210
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
211
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
212
+ '_bc ' => $ processor ->get_breadcrumbs (),
213
+ '_virtual ' => $ is_virtual (),
214
+ '_depth ' => $ get_current_depth (),
215
215
'_namespace ' => method_exists ( WP_HTML_Processor::class, 'get_namespace ' ) ? $ processor ->get_namespace () : 'html ' ,
216
216
);
217
217
218
218
// Self-contained tags contain their inner contents as modifiable text.
219
219
$ modifiable_text = $ processor ->get_modifiable_text ();
220
220
if ( '' !== $ modifiable_text ) {
221
221
$ self ['childNodes ' ][] = array (
222
- 'nodeType ' => NODE_TYPE_TEXT ,
223
- 'nodeName ' => '#text ' ,
222
+ 'nodeType ' => NODE_TYPE_TEXT ,
223
+ 'nodeName ' => '#text ' ,
224
224
'nodeValue ' => $ modifiable_text ,
225
- '_span ' => null ,
226
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
227
- '_bc ' => array_merge ( $ processor ->get_breadcrumbs (), array ( '#text ' ) ),
228
- '_virtual ' => $ is_virtual (),
229
- '_depth ' => $ get_current_depth () + 1 ,
225
+ '_span ' => null ,
226
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
227
+ '_bc ' => array_merge ( $ processor ->get_breadcrumbs (), array ( '#text ' ) ),
228
+ '_virtual ' => $ is_virtual (),
229
+ '_depth ' => $ get_current_depth () + 1 ,
230
230
);
231
231
}
232
232
@@ -244,70 +244,70 @@ function get_tree( string $html, array $options ): array {
244
244
245
245
case '#text ' :
246
246
$ self = array (
247
- 'nodeType ' => NODE_TYPE_TEXT ,
248
- 'nodeName ' => $ processor ->get_token_name (),
247
+ 'nodeType ' => NODE_TYPE_TEXT ,
248
+ 'nodeName ' => $ processor ->get_token_name (),
249
249
'nodeValue ' => $ processor ->get_modifiable_text (),
250
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
251
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
252
- '_bc ' => $ processor ->get_breadcrumbs (),
253
- '_virtual ' => $ is_virtual (),
254
- '_depth ' => $ get_current_depth (),
250
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
251
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
252
+ '_bc ' => $ processor ->get_breadcrumbs (),
253
+ '_virtual ' => $ is_virtual (),
254
+ '_depth ' => $ get_current_depth (),
255
255
);
256
256
257
257
$ current ['childNodes ' ][] = $ self ;
258
258
break ;
259
259
260
260
case '#cdata-section ' :
261
261
$ self = array (
262
- 'nodeType ' => NODE_TYPE_CDATA_SECTION ,
263
- 'nodeName ' => $ processor ->get_token_name (),
262
+ 'nodeType ' => NODE_TYPE_CDATA_SECTION ,
263
+ 'nodeName ' => $ processor ->get_token_name (),
264
264
'nodeValue ' => $ processor ->get_modifiable_text (),
265
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
266
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
267
- '_bc ' => $ processor ->get_breadcrumbs (),
268
- '_virtual ' => $ is_virtual (),
269
- '_depth ' => $ get_current_depth (),
265
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
266
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
267
+ '_bc ' => $ processor ->get_breadcrumbs (),
268
+ '_virtual ' => $ is_virtual (),
269
+ '_depth ' => $ get_current_depth (),
270
270
);
271
271
272
272
$ current ['childNodes ' ][] = $ self ;
273
273
break ;
274
274
275
275
case '#presumptuous-tag ' :
276
276
$ self = array (
277
- 'nodeType ' => NODE_TYPE_COMMENT ,
278
- 'nodeName ' => $ processor ->get_token_name (),
277
+ 'nodeType ' => NODE_TYPE_COMMENT ,
278
+ 'nodeName ' => $ processor ->get_token_name (),
279
279
'nodeValue ' => $ processor ->get_modifiable_text (),
280
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
281
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
282
- '_bc ' => $ processor ->get_breadcrumbs (),
283
- '_virtual ' => $ is_virtual (),
284
- '_depth ' => $ get_current_depth (),
280
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
281
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
282
+ '_bc ' => $ processor ->get_breadcrumbs (),
283
+ '_virtual ' => $ is_virtual (),
284
+ '_depth ' => $ get_current_depth (),
285
285
);
286
286
$ current ['childNodes ' ][] = $ self ;
287
287
break ;
288
288
289
289
case '#funky-comment ' :
290
290
$ self = array (
291
- 'nodeType ' => NODE_TYPE_COMMENT ,
292
- 'nodeName ' => $ processor ->get_token_name (),
291
+ 'nodeType ' => NODE_TYPE_COMMENT ,
292
+ 'nodeName ' => $ processor ->get_token_name (),
293
293
'nodeValue ' => $ processor ->get_modifiable_text (),
294
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
295
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
296
- '_bc ' => $ processor ->get_breadcrumbs (),
297
- '_virtual ' => $ is_virtual (),
298
- '_depth ' => $ get_current_depth (),
294
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
295
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
296
+ '_bc ' => $ processor ->get_breadcrumbs (),
297
+ '_virtual ' => $ is_virtual (),
298
+ '_depth ' => $ get_current_depth (),
299
299
);
300
300
$ current ['childNodes ' ][] = $ self ;
301
301
break ;
302
302
303
303
case '#comment ' :
304
304
$ self = array (
305
305
'nodeType ' => NODE_TYPE_COMMENT ,
306
- '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
307
- '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
308
- '_bc ' => $ processor ->get_breadcrumbs (),
306
+ '_span ' => $ processor_bookmarks ->getValue ( $ processor )[ $ processor_state ->getValue ( $ processor )->current_token ->bookmark_name ],
307
+ '_mode ' => $ processor_state ->getValue ( $ processor )->insertion_mode ,
308
+ '_bc ' => $ processor ->get_breadcrumbs (),
309
309
'_virtual ' => $ is_virtual (),
310
- '_depth ' => $ get_current_depth (),
310
+ '_depth ' => $ get_current_depth (),
311
311
);
312
312
switch ( $ processor ->get_comment_type () ) {
313
313
case WP_HTML_Processor::COMMENT_AS_ABRUPTLY_CLOSED_COMMENT :
@@ -321,7 +321,7 @@ function get_tree( string $html, array $options ): array {
321
321
$ self ['childNodes ' ] = array (
322
322
array (
323
323
'nodeType ' => NODE_TYPE_PROCESSING_INSTRUCTION ,
324
- 'nodeName ' => $ processor ->get_tag (),
324
+ 'nodeName ' => $ processor ->get_tag (),
325
325
'nodeValue ' => $ processor ->get_modifiable_text (),
326
326
),
327
327
);
@@ -367,9 +367,9 @@ function get_tree( string $html, array $options ): array {
367
367
}
368
368
369
369
return array (
370
- 'tree ' => $ tree ,
371
- 'compatMode ' => $ compat_mode ,
372
- 'doctypeName ' => $ doctype_name ,
370
+ 'tree ' => $ tree ,
371
+ 'compatMode ' => $ compat_mode ,
372
+ 'doctypeName ' => $ doctype_name ,
373
373
'doctypePublicId ' => $ doctype_public_identifier ,
374
374
'doctypeSystemId ' => $ doctype_system_identifier ,
375
375
);
0 commit comments