Make WordPress Core


Ignore:
Timestamp:
12/13/2023 05:51:42 PM (15 months ago)
Author:
Bernhard Reiter
Message:

HTML API: Add support for H1-H6 elements in the HTML Processor.

Previously these have been unsupported, but in this patch, support is added for the tags so that the HTML Processor can process documents containing them.

There was a design discussion about introducing a constant to communicate "any of the H1 - H6 elements" but this posed a number of challenges that don't need to be answered in this patch. For the time being, because the HTML specification treats H1 - H6 specially as a single kind of element, the HTML Processor uses an internal hard-coded string to indicate this. By using a hard-coded string it's possible to avoid introducing a class constant which cannot be made private due to PHP's class design. In the future, this will probably appear as a special constant in a new constant-containing class.

Props dmsnell, jonsurrell.
Fixes #60060.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/html-api/wpHtmlProcessorSemanticRules.php

    r57115 r57186  
    121121     *
    122122     * @ticket 58961
    123      *
    124      * @since 6.4.0
    125      *
    126      * @throws Exception
    127123     */
    128124    public function test_in_body_skips_unexpected_button_closer() {
     
    146142     *
    147143     * @ticket 58961
    148      *
    149      * @since 6.4.0
    150      *
    151      * @throws WP_HTML_Unsupported_Exception
    152144     */
    153145    public function test_in_body_button_with_no_button_in_scope() {
     
    175167     *
    176168     * @since 6.4.0
    177      *
    178      * @throws WP_HTML_Unsupported_Exception
    179169     */
    180170    public function test_in_body_button_with_button_in_scope_as_parent() {
     
    210200     *
    211201     * @since 6.4.0
    212      *
    213      * @throws WP_HTML_Unsupported_Exception
    214202     */
    215203    public function test_in_body_button_with_button_in_scope_as_ancestor() {
     
    237225    }
    238226
    239     /*
     227    /**
    240228     * Verifies that when "in body" and encountering "any other end tag"
    241229     * that the HTML processor ignores the end tag if there's a special
     
    260248    }
    261249
    262     /*
     250    /**
    263251     * Verifies that when "in body" and encountering "any other end tag"
    264252     * that the HTML processor closes appropriate elements on the stack of
Note: See TracChangeset for help on using the changeset viewer.