P tags are now corrects

Put the closing tags at end of line to be more readable


git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1287 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-05-12 12:55:55 +00:00
parent 5a0171caa7
commit 8d16811eff

View File

@@ -19,6 +19,7 @@ class markdown
@param string $mark Message in markdown syntax to display */
public function html ($mark)
{
unlink ("/tmp/debug");
$res = "";
$mark = htmlentities ($mark, ENT_QUOTES);
@@ -47,7 +48,8 @@ class markdown
return the html */
private function paragraph ($mark)
{
$timeStart = microtime (TRUE);
$timeStart = microtime (TRUE);
$timeregex = 0;
// Initialization of convertions
$search = array ();
$replace = array ();
@@ -173,20 +175,23 @@ $timeStart = microtime (TRUE);
array_pop ($htmlStack);
}
// Remove last \n to put closing tag at the end of line
$res = substr ($res, 0, -1);
$oldType = array_pop ($typeStack);
if ($oldType === "code")
{
debugMKD (str_repeat (" ", end ($indentStack))."</code></pre>");
$res .= str_repeat (" ", end ($indentStack))."</code></pre>\n";
debugMKD ("</code></pre>");
$res .= "</code></pre>\n";
array_pop ($htmlStack);
array_pop ($indentStack);
}
else
{
debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
$res .= str_repeat (" ", end ($indentStack))."</$oldType>\n";
}
array_pop ($htmlStack);
array_pop ($indentStack);
array_pop ($htmlStack);
if ($type === "ol" || $type === "ul")
{
debugMKD ("DEB2 : Pending <Li> : closing");
@@ -204,7 +209,7 @@ $timeStart = microtime (TRUE);
}
}
if ($indent == end ($indentStack) && $type !== "" && end ($typeStack))
if ($indent == end ($indentStack))
{
debugMKD ("DEB1 : Continuous block $type/".end ($typeStack));
if (end ($htmlStack) === "li")
@@ -218,16 +223,25 @@ $timeStart = microtime (TRUE);
if ($type !== end ($typeStack))
{
debugMKD ("DEB2 : Continuous Block but type change");
$oldType = array_pop ($typeStack);
debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
$res .= "\n".str_repeat (" ", end ($indentStack))."</$oldType>";
array_pop ($htmlStack);
if (end ($typeStack) !== FALSE)
{
// Remove last \n to put closing tag at the end of line
$res = substr ($res, 0, -1);
$oldType = array_pop ($typeStack);
debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
$res .= str_repeat (" ", end ($indentStack))."</$oldType>";
array_pop ($indentStack);
array_pop ($htmlStack);
}
debugMKD (str_repeat (" ", end ($indentStack))."<$type>");
$res .= "\n".str_repeat (" ", end ($indentStack))."<$type>";
$htmlStack[] = $type;
array_push ($indentStack, $indent);
array_push ($typeStack, $type);
if ($type !== "")
{
debugMKD (str_repeat (" ", end ($indentStack))."<$type>");
$res .= "\n".str_repeat (" ", end ($indentStack))."<$type>";
$htmlStack[] = $type;
array_push ($indentStack, $indent);
array_push ($typeStack, $type);
}
}
if ($type === "ol" || $type === "ul")
@@ -259,9 +273,12 @@ $timeStart = microtime (TRUE);
if (end ($typeStack))
{
debugMKD ("DEB2 : CODE : Close older HTML");
// Remove last \n to put closing tag at the end of line
$res = substr ($res, 0, -1);
$oldType = array_pop ($typeStack);
debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
$res .= str_repeat (" ", end ($indentStack))."</$oldType>";
array_pop ($indentStack);
array_pop ($htmlStack);
}
$typetmp = "pre><code";
@@ -290,21 +307,14 @@ $timeStart = microtime (TRUE);
if ($type === "" && end ($indentStack))
{
debugMKD ("DEB2 : Empty type");
// Remove last \n to put closing tag at the end of line
$res = substr ($res, 0, -1);
$oldType = array_pop ($typeStack);
debugMKD (str_repeat (" ", end ($indentStack))."</$oldType>");
$res .= "\n".str_repeat (" ", end ($indentStack))."</$oldType>";
array_pop ($htmlStack);
}
// New paragraphs
/* if ($type === "p")
{
debugMKD ("DEB1 : Starting a new paragraph");
debugMKD (str_repeat (" ", $indent)."<$type>");
$res .= "\n".str_repeat (" ", $indent)."<$type>";
array_push ($typeStack, $type);
}*/
// If code, there is no emphasis, email, and other convertions
if ($type !== "code")
{