Skip to content

Commit 85de4aa

Browse files
committed
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 #5903 Props jonsurrell, dmsnell Fixes #60283 git-svn-id: https://develop.svn.wordpress.org/trunk@57317 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 91e51f9 commit 85de4aa

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
* - Containers: ADDRESS, BLOCKQUOTE, DETAILS, DIALOG, DIV, FOOTER, HEADER, MAIN, MENU, SPAN, SUMMARY.
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.
108108
* - Lists: DD, DL, DT, LI, OL, LI.
@@ -112,7 +112,7 @@
112112
* - Sectioning elements: ARTICLE, ASIDE, HR, NAV, SECTION.
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
118118
*
@@ -684,10 +684,12 @@ private function step_in_body() {
684684
case '-FOOTER':
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':
693695
case '-SUMMARY':
@@ -732,6 +734,18 @@ private function step_in_body() {
732734
$this->insert_html_element( $this->state->current_token );
733735
return true;
734736

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;
747+
return true;
748+
735749
/*
736750
* > An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"
737751
*/
@@ -1007,7 +1021,6 @@ private function step_in_body() {
10071021
case 'INPUT':
10081022
case 'LI':
10091023
case 'LINK':
1010-
case 'LISTING':
10111024
case 'MARQUEE':
10121025
case 'MATH':
10131026
case 'META':
@@ -1021,7 +1034,6 @@ private function step_in_body() {
10211034
case 'OPTION':
10221035
case 'PARAM':
10231036
case 'PLAINTEXT':
1024-
case 'PRE':
10251037
case 'RB':
10261038
case 'RP':
10271039
case 'RT':

tests/phpunit/tests/html-api/wpHtmlProcessor.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ public function data_unsupported_special_in_body_tags() {
254254
'IFRAME' => array( 'IFRAME' ),
255255
'INPUT' => array( 'INPUT' ),
256256
'LINK' => array( 'LINK' ),
257-
'LISTING' => array( 'LISTING' ),
258257
'MARQUEE' => array( 'MARQUEE' ),
259258
'MATH' => array( 'MATH' ),
260259
'META' => array( 'META' ),
@@ -267,7 +266,6 @@ public function data_unsupported_special_in_body_tags() {
267266
'OPTION' => array( 'OPTION' ),
268267
'PARAM' => array( 'PARAM' ),
269268
'PLAINTEXT' => array( 'PLAINTEXT' ),
270-
'PRE' => array( 'PRE' ),
271269
'RB' => array( 'RB' ),
272270
'RP' => array( 'RP' ),
273271
'RT' => array( 'RT' ),

tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ public function data_unsupported_elements() {
176176
'IFRAME',
177177
'INPUT',
178178
'LINK',
179-
'LISTING', // Deprecated, use PRE instead.
180179
'MARQUEE', // Deprecated.
181180
'MATH',
182181
'META',
@@ -188,7 +187,6 @@ public function data_unsupported_elements() {
188187
'OPTGROUP',
189188
'OPTION',
190189
'PLAINTEXT', // Neutralized.
191-
'PRE',
192190
'RB', // Neutralized.
193191
'RP',
194192
'RT',

0 commit comments

Comments
 (0)