@@ -321,4 +321,39 @@ public static function data_provider_serialize_doctype() {
321321 'Double quotes in system ID ' => array ( '<!DOCTYPE html SYSTEM \'"quoted" \'\> ' , '<!DOCTYPE html SYSTEM \'"quoted" \'> ' ),
322322 );
323323 }
324+
325+ /**
326+ * @ticket TBD
327+ *
328+ * @dataProvider data_provider_special_leading_newline_cases
329+ */
330+ public function test_special_leading_newline_handling ( string $ input , string $ expected ) {
331+ $ normalized = WP_HTML_Processor::normalize ( $ input );
332+ $ this ->assertEqualHTML ( $ expected , $ normalized );
333+ $ normalized_twice = WP_HTML_Processor::normalize ( $ normalized );
334+ $ this ->assertEqualHTML ( $ expected , $ normalized_twice );
335+ }
336+
337+ /**
338+ */
339+ public static function data_provider_special_leading_newline_cases () {
340+ return array (
341+ 'Leading newline in PRE ' => array (
342+ "<pre> \nline 1 \nline 2</pre> " ,
343+ "<pre>line 1 \nline 2</pre> " ,
344+ ),
345+ 'Double leading newline in PRE ' => array (
346+ "<pre> \n\nline 2 \nline 3</pre> " ,
347+ "<pre> \n\nline 2 \nline 3</pre> " ,
348+ ),
349+ 'Leading newline in TEXTAREA ' => array (
350+ "<textarea> \nline 1 \nline 2</textarea> " ,
351+ "<textarea>line 1 \nline 2</textarea> " ,
352+ ),
353+ 'Double leading newline in TEXTAREA ' => array (
354+ "<textarea> \n\nline 2 \nline 3</textarea> " ,
355+ "<textarea> \n\nline 2 \nline 3</textarea> " ,
356+ ),
357+ );
358+ }
324359}
0 commit comments