Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2482ea1
Tests: Update html5lib test data from WPT
sirreal Jul 3, 2026
082b840
Tests: Rename HTML API external suite to WPT
sirreal Jul 3, 2026
f3c7b3e
Tests: Update WPT workflow group name
sirreal Jul 3, 2026
5646973
Merge branch 'html-api-update-html5lib-wpt' into html-api/update-proc…
sirreal Jul 3, 2026
81d528c
Remove PI test skips
sirreal Jul 3, 2026
f51e56d
Update and rename test structure
sirreal Jul 3, 2026
0faa100
Update WPT dir
sirreal Jul 3, 2026
c2f47c8
Tag Processor: parse processing instructions per the HTML Standard
sirreal Jul 3, 2026
e3f60f6
HTML Processor: handle and serialize processing instruction tokens
sirreal Jul 3, 2026
134041e
WPT harness: serialize processing instructions in tree dumps, skip br…
sirreal Jul 3, 2026
c4cd77d
HTML Processor: only rewrite IMAGE to IMG for tag tokens
sirreal Jul 3, 2026
d7e0898
Merge branch 'html-api-update-html5lib-wpt' into html-api/update-proc…
sirreal Jul 3, 2026
5db5f4b
Update to latest version a315c382eac
sirreal Jul 6, 2026
c20858c
Merge branch 'trunk' into html-api-update-html5lib-wpt
sirreal Jul 6, 2026
f102e61
Add necessary PI skips
sirreal Jul 6, 2026
f134e89
Revert documentation change
sirreal Jul 6, 2026
45e1452
Remove unused JS files
sirreal Jul 6, 2026
f5ad313
Merge branch 'html-api-update-html5lib-wpt' into html-api/update-proc…
sirreal Jul 6, 2026
aaf76c2
Simplify PI normalization comment
sirreal Jul 6, 2026
0c7db12
Ensure PI data ending in `?` is serialized correctly
sirreal Jul 6, 2026
ca3d849
Update PI state docs
sirreal Jul 6, 2026
4fa13c8
Use "processing instruction" state
sirreal Jul 6, 2026
d655770
Update PI example
sirreal Jul 6, 2026
24eecae
Drop PI lookalike comments
sirreal Jul 6, 2026
d94eca0
Add phpstan-return to get_token_type
sirreal Jul 6, 2026
b87ea5b
Support set_modifiable_text on PI
sirreal Jul 7, 2026
860a887
Add and improve test method types
sirreal Jul 7, 2026
cc427f0
Merge branch 'trunk' into html-api/update-processing-instruction-parse
sirreal Jul 7, 2026
0721a4b
Update tree output for updated WPT
sirreal Jul 7, 2026
a66d0d4
Merge branch 'trunk' into html-api/update-processing-instruction-parse
sirreal Jul 7, 2026
2c74364
Use 2-start comments for better ide formatting
sirreal Jul 7, 2026
cb61c12
Handle PI in build_visual_html_tree/assertEqualHTML
sirreal Jul 7, 2026
754a7dc
Add visual tree tests
sirreal Jul 8, 2026
c344e29
Merge remote-tracking branch 'upstream/trunk' into html-api/update-pr…
sirreal Jul 8, 2026
0fb5916
Use a single lexical update for PI modifiable text
sirreal Jul 8, 2026
85111bd
Restore PI lookalike comment classification
sirreal Jul 8, 2026
3a6e464
Always write the ?> closer for processing instructions
sirreal Jul 8, 2026
4eee7ed
Remove stale claim about the spec PI serialization form
sirreal Jul 8, 2026
a2fbcb6
Clarify why PI support was added
sirreal Jul 8, 2026
b8eaaa3
Add/update PI bogus comment tests
sirreal Jul 8, 2026
1f6e2b4
Add pi lookalike token test
sirreal Jul 8, 2026
71724f2
Fix build_visual_html PI handling, improve test
sirreal Jul 8, 2026
7b4bd4b
Update XML pi-lookalike comment
sirreal Jul 8, 2026
692cbd1
Merge branch 'trunk' into html-api/update-processing-instruction-parse
sirreal Jul 8, 2026
7bab900
Simplify serialize PI explanation.
sirreal Jul 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,15 @@ public function serialize_token(): string {
$html .= "<!--{$this->get_full_comment_text()}-->";
break;

/**
* Processing instructions are serialized as `"<?" target " " data "?>"`.
*
* @see https://html.spec.whatwg.org/multipage/parsing.html#serialising-html-fragments
*/
case '#processing-instruction':
$html .= "<?{$this->get_tag()} {$this->get_modifiable_text()}?>";
break;
Comment on lines +1405 to +1412

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


case '#cdata-section':
$html .= "<![CDATA[{$this->get_modifiable_text()}]]>";
break;
Expand Down Expand Up @@ -1562,10 +1571,12 @@ private function step_initial(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -1628,10 +1639,12 @@ private function step_before_html(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -1733,10 +1746,12 @@ private function step_before_head(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -1832,10 +1847,12 @@ private function step_in_head(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -2158,10 +2175,12 @@ private function step_after_head(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -2318,6 +2337,7 @@ private function step_in_body(): bool {
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -3400,10 +3420,12 @@ private function step_in_table(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -3721,10 +3743,12 @@ private function step_in_column_group(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -4153,10 +4177,12 @@ private function step_in_select(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':

@sirreal sirreal Jul 6, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll assume this is the intention. This entire insertion mode is gone from the current version of the spec: #9298

$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -4378,12 +4404,14 @@ private function step_in_template(): bool {
/*
* > A character token
* > A comment token
* > A processing instruction token
* > A DOCTYPE token
*/
case '#text':
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
case 'html':
return $this->step_in_body();

Expand Down Expand Up @@ -4519,10 +4547,12 @@ private function step_after_body(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->bail( 'Content outside of BODY is unsupported.' );
break;

Expand Down Expand Up @@ -4612,10 +4642,12 @@ private function step_in_frameset(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -4732,10 +4764,12 @@ private function step_after_frameset(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_html_element( $this->state->current_token );
return true;

Expand Down Expand Up @@ -4802,10 +4836,12 @@ private function step_after_after_body(): bool {
switch ( $op ) {
/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->bail( 'Content outside of HTML is unsupported.' );
break;

Expand Down Expand Up @@ -4866,10 +4902,12 @@ private function step_after_after_frameset(): bool {
switch ( $op ) {
/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->bail( 'Content outside of HTML is unsupported.' );
break;

Expand Down Expand Up @@ -4989,10 +5027,12 @@ private function step_in_foreign_content(): bool {

/*
* > A comment token
* > A processing instruction token
*/
case '#comment':
case '#funky-comment':
case '#presumptuous-tag':
case '#processing-instruction':
$this->insert_foreign_element( $this->state->current_token, false );
return true;

Expand Down Expand Up @@ -5306,8 +5346,12 @@ public function get_tag(): ?string {
/*
* > A start tag whose tag name is "image"
* > Change the token's tag name to "img" and reprocess it. (Don't ask.)
*
* This only applies to tags; a processing instruction target or a
* comment which looks like a processing instruction may also report
* a tag name and must not be rewritten.
*/
return ( 'IMAGE' === $tag_name && 'html' === $this->get_namespace() )
return ( 'IMAGE' === $tag_name && 'html' === $this->get_namespace() && '#tag' === $this->get_token_type() )
? 'IMG'
: $tag_name;
}
Expand Down Expand Up @@ -5376,8 +5420,11 @@ public function get_token_name(): ?string {
* - `#doctype` when matched on a DOCTYPE declaration.
* - `#presumptuous-tag` when matched on an empty tag closer.
* - `#funky-comment` when matched on a funky comment.
* - `#processing-instruction` when matched on a processing instruction.
*
* @since 6.6.0 Subclassed for the HTML Processor.
* @since 7.1.0 Recognize processing instructions according to an HTML
* specification update.
*
* @return string|null What kind of token is matched, or null.
*/
Expand Down
Loading
Loading