From 00e2cbeef8ec00d74dfb2654e49efd35b7e5d59d Mon Sep 17 00:00:00 2001
From: Jukka Svahn
/', '
', $line);
+ $line = $whitespace . preg_replace('/
/', '
', $line);
if ($ext && $anon) {
- $out[count($out)-1] .= "\n".$line;
+ $out[count($out)-1] .= $line;
} elseif (!$eat) {
$out[] = $line;
}
+ if ($eat) {
+ $eatWhitespace = true;
+ } else {
+ $whitespace = '';
+ }
+
if (!$ext) {
$tag = 'p';
$atts = '';
@@ -1910,7 +1928,7 @@ protected function blocks($text)
$out[count($out)-1] .= $c1;
}
- return join("\n\n", $out);
+ return join('', $out);
}
/**
@@ -1985,7 +2003,7 @@ protected function fBlock($m)
$o2 = "";
$c2 = "
";
$c1 = "";
- $content = $this->shelve($this->rEncodeHTML(rtrim($content, "\n")."\n"));
+ $content = $this->shelve($this->rEncodeHTML($content));
} elseif ($tag == 'notextile') {
$content = $this->shelve($content);
$o1 = '';
@@ -1993,7 +2011,7 @@ protected function fBlock($m)
$c1 = '';
$c2 = '';
} elseif ($tag == 'pre') {
- $content = $this->shelve($this->rEncodeHTML(rtrim($content, "\n")."\n"));
+ $content = $this->shelve($this->rEncodeHTML($content));
$o1 = "";
$o2 = '';
$c2 = '';
@@ -2857,12 +2875,10 @@ protected function cleanWhiteSpace($text)
$out = preg_replace("/^\xEF\xBB\xBF|\x1A/", '', $text);
// Replaces CRLF and CR with single LF.
$out = preg_replace("/\r\n?/", "\n", $out);
- // Replaces line endings containing only whitespace with single LF.
+ // Removes leading tabs and spaces, if the line is otherwise empty.
$out = preg_replace("/^[ \t]*\n/m", "\n", $out);
- // Trim three or more LFs down to 2.
- $out = preg_replace("/\n{3,}/", "\n\n", $out);
- // Removes leading blank lines.
- $out = preg_replace("/^\n*/", "", $out);
+ // Removes leading and ending blank lines.
+ $out = trim($out, "\n");
return $out;
}
diff --git a/test/fixtures/basic.yaml b/test/fixtures/basic.yaml
index 445c0696..f54a6b9b 100644
--- a/test/fixtures/basic.yaml
+++ b/test/fixtures/basic.yaml
@@ -726,8 +726,7 @@ HTML Comments :
Comment
-->
<!-- Here is a comment block in a code block. -->
-
+ <!-- Here is a comment block in a code block. -->
URLs as non-links :
notes : Straight URL text sequences should not be converted to a hyperlink.
@@ -1329,10 +1328,21 @@ Code blocks, pre and exclusions :
You can't _*touch*_ *_this_*... Hammer time.
-
+ You can't _*touch*_ *_this_*... Hammer time.
And keep your (expect)mitts _*off*_ *_me_*
as well. About the <hr />
tag.
Code block
+ + + +with three empty lines
Aaaand, relax.
++ Basic span modifiers & glyphs: input: | This is the "start" and 'end'; and I'm stuck in '88!: With smd_g4llery's attributes where hëll_won't__fr33ze_over if I use apostrophes inside odd words and_underscores (Pah). @@ -1438,8 +1459,7 @@ Make sure these don't get turned into lists... : ; Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0 ; Expires: Sat, 24 Jul 2003 05:00:00 GMT ; Last-Modified: Wed, 1 Jan 2025 05:00:00 GMT - ; Pragma: no-cache - + ; Pragma: no-cacheParagraph 1
+ +Paragraph 2
+ +Paragraph 3
123 test