Make WordPress Core


Ignore:
Timestamp:
06/16/2026 09:48:47 AM (3 months ago)
Author:
jonsurrell
Message:

HTML API: Correct and improve documentation issues.

Developed in https://github.com/WordPress/wordpress-develop/pull/12043.

Props jonsurrell, westonruter, dmsnell.
See #64896.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php

    r62492 r62507  
    214214 * ### Bookmarks
    215215 *
    216  * While scanning through the input HTMl document it's possible to set
     216 * While scanning through the input HTML document it's possible to set
    217217 * a named bookmark when a particular tag is found. Later on, after
    218218 * continuing to scan other tags, it's possible to `seek` to one of
     
    287287 * For these elements the Tag Processor treats the entire sequence as one,
    288288 * from the opening tag, including its contents, through its closing tag.
    289  * This means that the it's not possible to match the closing tag for a
     289 * This means that it's not possible to match the closing tag for a
    290290 * SCRIPT element unless it's unexpected; the Tag Processor already matched
    291291 * it when it found the opening tag.
     
    299299 *  - `TITLE` and `TEXTAREA` whose contents are treated as plaintext and then any
    300300 *    character references are decoded. E.g. `1 &lt; 2 < 3` becomes `1 < 2 < 3`.
    301  *  - `IFRAME`, `NOSCRIPT`, `NOEMBED`, `NOFRAME`, `STYLE` whose contents are treated as
     301 *  - `IFRAME`, `NOEMBED`, `NOFRAMES`, `STYLE` whose contents are treated as
    302302 *    raw plaintext and left as-is. E.g. `1 &lt; 2 < 3` remains `1 &lt; 2 < 3`.
    303303 *
     
    330330 *      target names with an ASCII-representable subset of characters. It also exhibits the
    331331 *      same constraint as with CDATA sections, in that `>` cannot exist within the token
    332  *      since Processing Instructions do no exist within HTML and their syntax transforms
     332 *      since Processing Instructions do not exist within HTML and their syntax transforms
    333333 *      into a bogus comment in the DOM.
    334334 *
     
    522522         *
    523523         *   - In `QUIRKS_MODE`:
    524          *       - CSS class and ID selectors match match in an ASCII case-insensitive manner.
     524         *       - CSS class and ID selectors match in an ASCII case-insensitive manner.
    525525         *       - A TABLE start tag `<table>` opens a `TABLE` element as a child of a `P`
    526526         *         element if one is open.
     
    615615         *
    616616         *     <div id="test">...
    617          *     012345678901234
    618          *     - token length is 14 - 0 = 14
     617         *     0123456789012345
     618         *     - token length is 15 - 0 = 15
    619619         *
    620620         *     a <!-- comment --> is a token.
    621621         *     0123456789 123456789 123456789
    622          *     - token length is 17 - 2 = 15
     622         *     - token length is 18 - 2 = 16
    623623         *
    624624         * @since 6.5.0
     
    926926         *  - a DOCTYPE declaration.
    927927         *  - a processing instruction, e.g. `<?xml version="1.0" ?>`.
    928          *
    929          * The Tag Processor currently only supports the tag token.
    930928         *
    931929         * @since 6.5.0
     
    10741072                 * Preserve the opening tag pointers, as these will be overwritten
    10751073                 * when finding the closing tag. They will be reset after finding
    1076                  * the closing to tag to point to the opening of the special atomic
     1074                 * the closing tag to point to the opening of the special atomic
    10771075                 * tag sequence.
    10781076                 */
     
    11501148         *
    11511149         *     $processor = new WP_HTML_Tag_Processor( '<input type="text" value="Th' );
    1152          *     false      === $processor->get_next_tag();
     1150         *     false      === $processor->next_tag();
    11531151         *     true       === $processor->paused_at_incomplete_token();
    11541152         *
     
    25262524                 * at later string indices in the input document.
    25272525                 *
    2528                  * Sorting avoid making out-of-order replacements which
     2526                 * Sorting avoids making out-of-order replacements which
    25292527                 * can lead to mangled output, partially-duplicated
    25302528                 * attributes, and overwritten attributes.
     
    35623560         *     false === $processor->subdivide_text_appropriately();
    35633561         *
    3564          *     $processor = new WP_HTML_Tag_Processor( "&#x13; \r\n\tMore" );
    3565          *     true  === $processor->next_token();                   // Text is "␤ ␤␉More".
    3566          *     true  === $processor->subdivide_text_appropriately(); // Text is "␤ ␤␉".
     3562         *     $processor = new WP_HTML_Tag_Processor( "&#xD; \r\n\tMore" );
     3563         *     true  === $processor->next_token();                   // Text is "␍ ␊␉More".
     3564         *     true  === $processor->subdivide_text_appropriately(); // Text is "␍ ␊␉".
    35673565         *     true  === $processor->next_token();                   // Text is "More".
    35683566         *     false === $processor->subdivide_text_appropriately();
     
    49424940         *
    49434941         * Funky comments are tag closers with invalid tag names. Note
    4944          * that in HTML these are turn into bogus comments. Nonetheless,
     4942         * that in HTML these are turned into bogus comments. Nonetheless,
    49454943         * the Tag Processor recognizes them in a stream of HTML and
    49464944         * exposes them for inspection and modification.
Note: See TracChangeset for help on using the changeset viewer.