diff --git a/markdown.php b/markdown.php index 8e00b9e..dbbb45b 100644 --- a/markdown.php +++ b/markdown.php @@ -16,7 +16,7 @@ class markdown @param string $mark Message in markdown syntax to display */ public function html ($mark) { - //unlink ("/tmp/debug"); + if ($this->debug) unlink ("/tmp/debug"); $res = ""; $mark = htmlentities ($mark, ENT_QUOTES); @@ -133,6 +133,7 @@ class markdown $htmlStack = array (); $lines = explode ("\n", $mark); $timeInit = microtime (TRUE) - $timeStart; + $blockLI = false; foreach ($lines as $nb=>$line) { $this->debugMKD ("DEBUT:$line"); @@ -225,6 +226,16 @@ class markdown $this->debugMKD (""); $res .= ""; 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)) @@ -251,7 +262,7 @@ class markdown } } - if ($type === "ol" || $type === "ul") + if (($type === "ol" || $type === "ul") && $blockLI === false) { $this->debugMKD ("DEB2 : Adding li"); $htmlStack[] = "li";