Skip to content

Commit 9eb6360

Browse files
committed
Handline PRE,LISTING
1 parent 3618fc5 commit 9eb6360

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,21 +1359,21 @@ public function serialize_token(): string {
13591359

13601360
case '#text':
13611361
$text = $this->get_modifiable_text();
1362-
if (
1363-
WP_HTML_Tag_Processor::TEXT_IS_WHITESPACE === $this->text_node_classification &&
1364-
'PRE' === $this->state->stack_of_open_elements->at( $this->state->stack_of_open_elements->count() - 1 )?->node_name
1365-
) {
1366-
/*
1367-
* DO NOT DO THIS
1368-
* This case is exceptional and we must peek at processor internals.
1369-
*/
1370-
$newline_was_erased = Closure::bind(
1371-
fn () => $this->skip_newline_at === $this->token_starts_at,
1372-
$this,
1373-
WP_HTML_Tag_Processor::class
1374-
)();
1375-
if ( $newline_was_erased ) {
1376-
$text = "\n{$text}";
1362+
if ( WP_HTML_Tag_Processor::TEXT_IS_WHITESPACE === $this->text_node_classification ) {
1363+
$parent_node_name = $this->state->stack_of_open_elements->at( $this->state->stack_of_open_elements->count() - 1 )?->node_name;
1364+
if ( 'PRE' === $parent_node_name || 'LISTING' === $parent_node_name ) {
1365+
/*
1366+
* DO NOT DO THIS
1367+
* This case is exceptional and we must peek at processor internals.
1368+
*/
1369+
$newline_was_erased = Closure::bind(
1370+
fn () => $this->skip_newline_at === $this->token_starts_at,
1371+
$this,
1372+
WP_HTML_Tag_Processor::class
1373+
)();
1374+
if ( $newline_was_erased ) {
1375+
$text = "\n{$text}";
1376+
}
13771377
}
13781378
}
13791379
$html .= htmlspecialchars( $text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8' );

0 commit comments

Comments
 (0)