WordPress/wp-includes/html-api
dmsnell 2107b186fe HTML API: Report real and virtual nodes in the HTML Processor.
HTML is a kind of short-hand for a DOM structure. This means that there are
many cases in HTML where an element's opening tag or closing tag is missing (or
both). This is because many of the parsing rules imply creating elements in the
DOM which may not exist in the text of the HTML.

The HTML Processor, being the higher-level counterpart to the Tag Processor, is
already aware of these nodes, but since it's inception has not paused on them
when scanning through a document. Instead, these are visible when pausing on a
child of such an element, but otherwise not seen.

In this patch the HTML Processor starts exposing those implicitly-created nodes,
including opening tags, and closing tags, that aren't foudn in the text content
of the HTML input document.

Previously, the sequence of matched tokens when scanning with 
`WP_HTML_Processor::next_token()` would depend on how the HTML document was written,
but with this patch, all semantically equal HTML documents will parse and scan in
the same exact manner, presenting an idealized or "perfect" view of the document
the same way as would occur when traversing a DOM in a browser.

Developed in https://github.com/WordPress/wordpress-develop/pull/6348
Discussed in https://core.trac.wordpress.org/ticket/61348

Props audrasjb, dmsnell, gziolo, jonsurrell.
Fixes #61348.

Built from https://develop.svn.wordpress.org/trunk@58304


git-svn-id: http://core.svn.wordpress.org/trunk@57761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-06-03 19:47:15 +00:00
..
class-wp-html-active-formatting-elements.php HTML API: Apply linting changes to @TODO comments. 2023-12-20 12:36:31 +00:00
class-wp-html-attribute-token.php HTML API: Track spans of text with (offset, length) instead of (start, end). 2023-12-10 13:19:28 +00:00
class-wp-html-decoder.php HTML API: Add custom text decoder. 2024-06-02 15:16:13 +00:00
class-wp-html-open-elements.php HTML API: Report real and virtual nodes in the HTML Processor. 2024-06-03 19:47:15 +00:00
class-wp-html-processor-state.php HTML API: Store current token reference in HTML Processor state. 2023-09-12 15:12:17 +00:00
class-wp-html-processor.php HTML API: Report real and virtual nodes in the HTML Processor. 2024-06-03 19:47:15 +00:00
class-wp-html-span.php HTML API: Track spans of text with (offset, length) instead of (start, end). 2023-12-10 13:19:28 +00:00
class-wp-html-stack-event.php HTML API: Report real and virtual nodes in the HTML Processor. 2024-06-03 19:47:15 +00:00
class-wp-html-tag-processor.php HTML API: Add custom text decoder. 2024-06-02 15:16:13 +00:00
class-wp-html-text-replacement.php HTML API: Track spans of text with (offset, length) instead of (start, end). 2023-12-10 13:19:28 +00:00
class-wp-html-token.php HTML-API: Prevent unintended behavior when WP_HTML_Token is unserialized. 2023-12-06 16:05:19 +00:00
class-wp-html-unsupported-exception.php HTML-API: Introduce minimal HTML Processor. 2023-07-20 13:43:25 +00:00
html5-named-character-references.php Introduce Token Map: An optimized static translation class. 2024-05-23 19:56:08 +00:00