Now emmiting <br>s for newlines starting a flat code block (to aleviate inconsistant browser behaviour).

This commit is contained in:
Michel Fortin 2008-05-04 08:03:14 -04:00
parent 82c323389c
commit 6415572946

View file

@ -2396,9 +2396,15 @@ class MarkdownExtra_Parser extends Markdown_Parser {
function _doCodeBlocks_flat_callback($matches) {
$codeblock = $matches[2];
$codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES);
$codeblock = preg_replace_callback('/^\n+/',
array(&$this, '_doCodeBlocks_flat_newlines'), $codeblock);
$codeblock = "<pre><code>$codeblock</code></pre>";
return "\n\n".$this->hashBlock($codeblock)."\n\n";
}
function _doCodeBlocks_flat_newlines($matches) {
return str_repeat("<br$this->empty_element_suffix",
strlen($matches[0]));
}
function doItalicsAndBold($text) {