File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ' );
You can’t perform that action at this time.
0 commit comments