diff --git a/markdown.php b/markdown.php index 2e5f43c..9867826 100644 --- a/markdown.php +++ b/markdown.php @@ -149,27 +149,36 @@ class markdown $type = $this->paragraphType ($line); $this->debugMKD ("DEBUT: Type='$type'"); $matches = array (); - switch ($type) + $indent = strspn ($line, " "); + if (end ($typeStack) === "code" && $indent >= end ($indentStack)) { - case "ol" : - preg_match ("/^( *)[0-9]+\. +(.*)/", $line, $matches); - if (!isset ($matches[2])) - $lineTxt = $line; - else - $lineTxt = $matches[2]; - break ; - case "ul" : - preg_match ("/^( *)[-+*] +(.*)/", $line, $matches); - if (!isset ($matches[2])) - $lineTxt = $line; - else - $lineTxt = $matches[2]; - break ; - default: + $this->debugMKD ("DEBUT: Force type=CODE"); + $type = "code"; $lineTxt = $line; } + else + { + switch ($type) + { + case "ol" : + preg_match ("/^( *)[0-9]+\. +(.*)/", $line, $matches); + if (!isset ($matches[2])) + $lineTxt = $line; + else + $lineTxt = $matches[2]; + break ; + case "ul" : + preg_match ("/^( *)[-+*] +(.*)/", $line, $matches); + if (!isset ($matches[2])) + $lineTxt = $line; + else + $lineTxt = $matches[2]; + break ; + default: + $lineTxt = $line; + } + } - $indent = strspn ($line, " "); $this->debugMKD ("DEBUT: Indent='$indent'"); $this->debugMKD ("DEBUT: indentStack=".print_r ($indentStack, TRUE)); $this->debugMKD ("DEBUT: typeStack=".print_r ($typeStack, TRUE));