Make WordPress Core


Ignore:
Timestamp:
11/17/2023 06:11:31 AM (3 years ago)
Author:
Bernhard Reiter
Message:

HTML API: Add support for containers elements, including ARTICLE.

There are a handful of elements which behave similarly and are generically container elements. These are the following elements:

ADDRESS, ARTICLE, ASIDE, BLOCKQUOTE, CENTER, DETAILS, DIALOG, DIR,
DL, DIV, FIELDSET, FIGCAPTION, FIGURE, FOOTER, HEADER, HGROUP, MAIN,
MENU, NAV, SEARCH, SECTION, SUMMARY

This patch adds support to the HTML Processor for handling these elements. They do not require any additional logic in the rest of the class, and carry no specific semantic rules for parsing beyond what is listed in their group in the IN BODY section of the HTML5 specification.

Props dmsnell.
Fixes #59914.

File:
1 edited

Legend:

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

    r57077 r57115  
    100100 * The following list specifies the HTML tags that _are_ supported:
    101101 *
     102 *  - Containers: ADDRESS, BLOCKQUOTE, DETAILS, DIALOG, DIV, FOOTER, HEADER, MAIN, MENU, SPAN, SUMMARY.
     103 *  - Form elements: BUTTON, FIELDSET, SEARCH.
     104 *  - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U.
     105 *  - Heading elements: HGROUP.
    102106 *  - Links: A.
    103  *  - The formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U.
    104  *  - Containers: DIV, FIGCAPTION, FIGURE, SPAN.
    105  *  - Form elements: BUTTON.
     107 *  - Lists: DL.
     108 *  - Media elements: FIGCAPTION, FIGURE, IMG.
    106109 *  - Paragraph: P.
    107  *  - Void elements: IMG.
     110 *  - Sectioning elements: ARTICLE, ASIDE, NAV, SECTION
     111 *  - Deprecated elements: CENTER, DIR
    108112 *
    109113 * ### Supported markup
     
    622626                         * > "main", "menu", "nav", "ol", "p", "search", "section", "summary", "ul"
    623627                         */
     628                        case '+ADDRESS':
     629                        case '+ARTICLE':
     630                        case '+ASIDE':
    624631                        case '+BLOCKQUOTE':
     632                        case '+CENTER':
     633                        case '+DETAILS':
     634                        case '+DIALOG':
     635                        case '+DIR':
    625636                        case '+DIV':
     637                        case '+DL':
     638                        case '+FIELDSET':
    626639                        case '+FIGCAPTION':
    627640                        case '+FIGURE':
     641                        case '+FOOTER':
     642                        case '+HEADER':
     643                        case '+HGROUP':
     644                        case '+MAIN':
     645                        case '+MENU':
     646                        case '+NAV':
    628647                        case '+P':
     648                        case '+SEARCH':
     649                        case '+SECTION':
     650                        case '+SUMMARY':
    629651                                if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
    630652                                        $this->close_a_p_element();
     
    640662                         * > "menu", "nav", "ol", "pre", "search", "section", "summary", "ul"
    641663                         */
     664                        case '-ADDRESS':
     665                        case '-ARTICLE':
     666                        case '-ASIDE':
    642667                        case '-BLOCKQUOTE':
    643668                        case '-BUTTON':
     669                        case '-CENTER':
     670                        case '-DETAILS':
     671                        case '-DIALOG':
     672                        case '-DIR':
    644673                        case '-DIV':
     674                        case '-DL':
     675                        case '-FIELDSET':
    645676                        case '-FIGCAPTION':
    646677                        case '-FIGURE':
     678                        case '-FOOTER':
     679                        case '-HEADER':
     680                        case '-HGROUP':
     681                        case '-MAIN':
     682                        case '-MENU':
     683                        case '-NAV':
     684                        case '-SEARCH':
     685                        case '-SECTION':
     686                        case '-SUMMARY':
    647687                                if ( ! $this->state->stack_of_open_elements->has_element_in_scope( $tag_name ) ) {
    648688                                        // @TODO: Report parse error.
Note: See TracChangeset for help on using the changeset viewer.