File tree Expand file tree Collapse file tree
tests/phpunit/tests/html-api Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments