Skip to content

Commit 993fe2b

Browse files
committed
Add newline in PRE tests
1 parent ce87818 commit 993fe2b

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,27 @@ public static function data_pre_element_leading_newline() {
749749
"<pre>line1\nline2</pre>",
750750
),
751751

752+
/*
753+
* This may seem wrong, but the template is processed like HTML. The leading newline
754+
* is removed.
755+
* The newline inside the replacement is rendered as HTML and is also removed.
756+
*
757+
* The correct way to do this for a PRE tag is:
758+
* - Leading newline in template is irrelevant.
759+
* - Replacement must include an extra newline to lead with a newline in the output.
760+
*
761+
* See the next case.
762+
*/
752763
'PRE with newline and newline in replacement' => array(
753764
"<pre>\n</%code></pre>",
754-
array( 'code' => "\nline1\nline2"),
755-
"<pre>\nline1\nline2</pre>",
765+
array( 'code' => "\nline1\nline2" ),
766+
"<pre>\n\nline1\nline2</pre>",
767+
),
768+
769+
'PRE with newline and double-newline in replacement' => array(
770+
"<pre>\n</%code></pre>",
771+
array( 'code' => "\nline1\nline2" ),
772+
"<pre>\n\nline1\nline2</pre>",
756773
),
757774
);
758775
}

0 commit comments

Comments
 (0)