markdown : BUG : - line1\nline2 : should be the continuity of <li>, not <p>
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1487 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
15
markdown.php
15
markdown.php
@@ -16,7 +16,7 @@ class markdown
|
|||||||
@param string $mark Message in markdown syntax to display */
|
@param string $mark Message in markdown syntax to display */
|
||||||
public function html ($mark)
|
public function html ($mark)
|
||||||
{
|
{
|
||||||
//unlink ("/tmp/debug");
|
if ($this->debug) unlink ("/tmp/debug");
|
||||||
$res = "";
|
$res = "";
|
||||||
$mark = htmlentities ($mark, ENT_QUOTES);
|
$mark = htmlentities ($mark, ENT_QUOTES);
|
||||||
|
|
||||||
@@ -133,6 +133,7 @@ class markdown
|
|||||||
$htmlStack = array ();
|
$htmlStack = array ();
|
||||||
$lines = explode ("\n", $mark);
|
$lines = explode ("\n", $mark);
|
||||||
$timeInit = microtime (TRUE) - $timeStart;
|
$timeInit = microtime (TRUE) - $timeStart;
|
||||||
|
$blockLI = false;
|
||||||
foreach ($lines as $nb=>$line)
|
foreach ($lines as $nb=>$line)
|
||||||
{
|
{
|
||||||
$this->debugMKD ("DEBUT:$line");
|
$this->debugMKD ("DEBUT:$line");
|
||||||
@@ -225,6 +226,16 @@ class markdown
|
|||||||
$this->debugMKD ("</li>");
|
$this->debugMKD ("</li>");
|
||||||
$res .= "</li>";
|
$res .= "</li>";
|
||||||
array_pop ($htmlStack);
|
array_pop ($htmlStack);
|
||||||
|
$blockLI = false;
|
||||||
|
}
|
||||||
|
elseif (end ($htmlStack) === "li" && $type === "p")
|
||||||
|
{
|
||||||
|
$this->debugMKD ("DEB2 : Continuous LI block");
|
||||||
|
// Suppress \n on last line
|
||||||
|
$res = substr ($res, 0, -1);
|
||||||
|
$type = "ul";
|
||||||
|
$blockLI = true;
|
||||||
|
$lineTxt = " ".$lineTxt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type !== end ($typeStack))
|
if ($type !== end ($typeStack))
|
||||||
@@ -251,7 +262,7 @@ class markdown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === "ol" || $type === "ul")
|
if (($type === "ol" || $type === "ul") && $blockLI === false)
|
||||||
{
|
{
|
||||||
$this->debugMKD ("DEB2 : Adding li");
|
$this->debugMKD ("DEB2 : Adding li");
|
||||||
$htmlStack[] = "li";
|
$htmlStack[] = "li";
|
||||||
|
|||||||
Reference in New Issue
Block a user