From 18fe0913ae2c69eb1adc940af37c5b231e1374f9 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 30 Jun 2014 12:11:52 +0000 Subject: [PATCH] markdown : BUG : Correct the "code" section : don't allow ul/li in codes, print */- normally git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1508 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- markdown.php | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) 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));