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
This commit is contained in:
2014-09-03 15:00:17 +00:00
parent 20d4c4ec57
commit 3f0adcdf11
2 changed files with 20 additions and 1 deletions

View File

@@ -323,4 +323,14 @@ end"));
$md = new markdown ();
printf ($md->html ("line1 \nline2\n"));
}
public function testCarriageReturn3 ()
{
$this->expectOutputString("<p>line1 line2 line3.</p>");
$md = new markdown ();
$md->debug = 1;
printf ($md->html ("line1
line2
line3."));
}
}

View File

@@ -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<p></p>", "", $res);
$res = str_replace ("<p></p>", "", $res);
$res = str_replace ("<p> </p>", "", $res);
$res = str_replace ("<p>\n</p>\n", "", $res);
return $res;
}
@@ -261,6 +262,14 @@ class markdown
$lineTxt = " ".$lineTxt;
}
if (end ($htmlStack) === "p" && $type === "p" &&
substr ($res, -5) !== "<br/>")
{
// Add a space to agregate two lines
$this->debugMKD ("DEB2 : Adding aggragate space");
$res .= " ";
}
if ($type !== end ($typeStack))
{
$this->debugMKD ("DEB2 : Continuous Block but type change");