Make WordPress Core


Ignore:
Timestamp:
01/19/2024 10:05:37 PM (10 months ago)
Author:
dmsnell
Message:

HTML API: Add support for PRE and LISTING elements.

Adds support for the following HTML elements to the HTML Processor:

  • PRE, LISTING

Previously, these elements were not supported and the HTML Processor would bail when encountering them. Now, with this patch applied, it will proceed to parse an HTML document when encountering those tags.

Developed in WordPress/wordpress-develop#5903

Props jonsurrell, dmsnell
Fixes #60283

File:
1 edited

Legend:

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

    r57316 r57317  
    103103 *  - Custom elements: All custom elements are supported. :)
    104104 *  - Form elements: BUTTON, DATALIST, FIELDSET, LABEL, LEGEND, METER, PROGRESS, SEARCH.
    105  *  - Formatting elements: B, BIG, CODE, EM, FONT, I, SMALL, STRIKE, STRONG, TT, U, WBR.
     105 *  - Formatting elements: B, BIG, CODE, EM, FONT, I, PRE, SMALL, STRIKE, STRONG, TT, U, WBR.
    106106 *  - Heading elements: H1, H2, H3, H4, H5, H6, HGROUP.
    107107 *  - Links: A.
     
    113113 *  - Templating elements: SLOT.
    114114 *  - Text decoration: RUBY.
    115  *  - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, KEYGEN, MULTICOL, NEXTID, SPACER.
     115 *  - Deprecated elements: ACRONYM, BLINK, CENTER, DIR, ISINDEX, KEYGEN, LISTING, MULTICOL, NEXTID, SPACER.
    116116 *
    117117 * ### Supported markup
     
    685685            case '-HEADER':
    686686            case '-HGROUP':
     687            case '-LISTING':
    687688            case '-MAIN':
    688689            case '-MENU':
    689690            case '-NAV':
    690691            case '-OL':
     692            case '-PRE':
    691693            case '-SEARCH':
    692694            case '-SECTION':
     
    731733
    732734                $this->insert_html_element( $this->state->current_token );
     735                return true;
     736
     737            /*
     738             * > A start tag whose tag name is one of: "pre", "listing"
     739             */
     740            case '+PRE':
     741            case '+LISTING':
     742                if ( $this->state->stack_of_open_elements->has_p_in_button_scope() ) {
     743                    $this->close_a_p_element();
     744                }
     745                $this->insert_html_element( $this->state->current_token );
     746                $this->state->frameset_ok = false;
    733747                return true;
    734748
     
    10081022            case 'LI':
    10091023            case 'LINK':
    1010             case 'LISTING':
    10111024            case 'MARQUEE':
    10121025            case 'MATH':
     
    10221035            case 'PARAM':
    10231036            case 'PLAINTEXT':
    1024             case 'PRE':
    10251037            case 'RB':
    10261038            case 'RP':
Note: See TracChangeset for help on using the changeset viewer.