From 3f0adcdf11577e86d37f16e605ae00b6f656ea10 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 3 Sep 2014 15:00:17 +0000 Subject: [PATCH] Markdown : add a space in the middle of two concatanated lines git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1796 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- Tests/markdownTest.php | 10 ++++++++++ markdown.php | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Tests/markdownTest.php b/Tests/markdownTest.php index bb954d8..8fa3f18 100644 --- a/Tests/markdownTest.php +++ b/Tests/markdownTest.php @@ -323,4 +323,14 @@ end")); $md = new markdown (); printf ($md->html ("line1 \nline2\n")); } + + public function testCarriageReturn3 () + { + $this->expectOutputString("

line1 line2 line3.

"); + $md = new markdown (); + $md->debug = 1; + printf ($md->html ("line1 +line2 +line3.")); + } } diff --git a/markdown.php b/markdown.php index 4af06be..4d98117 100644 --- a/markdown.php +++ b/markdown.php @@ -41,13 +41,14 @@ class markdown // End of line with continuous on second line, without double spaces : add // space - $search[] = "/^(\w+)\\n(\w+)/m"; $replace[] = "\\1 \\2"; + //$search[] = "/(\w+)\\n(\w+)/Um"; $replace[] = "\\1 \\2"; $mark = preg_replace ($search, $replace, $mark); $res = $this->paragraph ($mark); $res = str_replace ("\n

", "", $res); $res = str_replace ("

", "", $res); + $res = str_replace ("

", "", $res); $res = str_replace ("

\n

\n", "", $res); return $res; } @@ -260,6 +261,14 @@ class markdown $blockLI = true; $lineTxt = " ".$lineTxt; } + + if (end ($htmlStack) === "p" && $type === "p" && + substr ($res, -5) !== "
") + { + // Add a space to agregate two lines + $this->debugMKD ("DEB2 : Adding aggragate space"); + $res .= " "; + } if ($type !== end ($typeStack)) {