\n"); } elseif ("#" == $line1) { preg_match("/^(#{1,3})\s*(.*)/", $line, $sharps); $h_level = strlen($sharps[1]); $text = $sharps[2]; switch ($h_level) { case 1: print("
\n"); } elseif (">" == $line1) { $mode = "quote"; preg_match("/^>\s*(.*)$/", $line, $quoteParts); $quote = $quoteParts[1]; print("\n"); } else { print($line."\n"); } } elseif ("quote"==$mode) { if (">" == $line1) { preg_match("/^>\s*(.*)$/", $line, $quoteParts); $quote = $quoteParts[1]; if (empty($quote)) print("\n"); if (empty($quote)) print("\n"); else print("
".$quoteParts[1]."
\n"); } elseif ("*" == $line1) { $mode = "ul"; $reDo = true; print("\n"); } else { print("
".$line."
\n"); } } elseif ("pre"==$mode) { if ("```" == $line3) { $mode=null; print("
\n"); else print("
".$quote."
\n"); } else { print("\n"); $mode=null; $reDo=true; } } elseif ("ul"==$mode) { if ("*" == $line1) { preg_match("/^\*\s*(.*)$/", $line, $ulParts); $li = $ulParts[1]; if (empty($li)) print("