diff --git a/markdown.php b/markdown.php index 6f50985..c69724a 100644 --- a/markdown.php +++ b/markdown.php @@ -20,11 +20,37 @@ class markdown public function html ($mark) { $res = ""; - $search = array (); - $replace = array (); - $mark = htmlentities ($mark, ENT_QUOTES); + // Here are the regexp on multilines + $search = array (); + $replace = array (); + // Titles with underline (SeText) + // Titre1 + // ====== + $search[] = "/^(.+)\\n==+$\\n/Um"; + $replace[] = "\n
"; - // Titles with underline (SeText) - // Titre1 - // ====== - $search[] = "/\\n^(.+)\\n==+$\\n/Um"; - $replace[] = "
\n"; - // Titre2 - // ------ - $search[] = "/^(.+)\\n--+$\\n/Um"; - $replace[] = "\n
");
- $res .= "\n".str_repeat (" ", $indent)."<$type>";
+ debugMKD (str_repeat (" ", $indent)."<$typetmp>");
+ $res .= "\n".str_repeat (" ", $indent)."<$typetmp>";
if ($type === "ol" || $type === "ul")
{
debugMKD ("DEB2 : Adding li");
@@ -284,6 +294,14 @@ class markdown
array_pop ($htmlStack);
}
+ // If code, there is no emphasis, email, and other convertions
+ if ($type !== "code")
+ {
+ $timetmp = microtime (TRUE);
+ $lineTxt = preg_replace ($search, $replace, $lineTxt);
+ $timeregex += (microtime (TRUE) - $timetmp);
+ }
+
debugMKD ("$lineTxt");
$res .= "$lineTxt\n";
}
@@ -296,6 +314,9 @@ class markdown
$res .= "$type>\n";
}
+ debugMKD ("TimeInit=".($timeInit*1000)."ms");
+ debugMKD ("TimeRegex=".($timeregex*1000)."ms");
+ debugMKD ("TimeAll=".((microtime (TRUE) - $timeStart)*1000)."ms");
debugMKD ("-----------\n");
return $res;
}