diff --git a/markdown.php b/markdown.php index d296dfd..fb4527f 100644 --- a/markdown.php +++ b/markdown.php @@ -2554,7 +2554,7 @@ class MarkdownExtra_Parser extends Markdown_Parser { ) # 2: CSS classes - \s?(\.[^\n]+)? + [ ]*(\.[^\n]+)? [ ]* \n # Whitespace and newline following marker. @@ -2570,7 +2570,7 @@ class MarkdownExtra_Parser extends Markdown_Parser { \1 # 4: CSS classes - \s?(\.[^\n]+)? + [ ]*(\.[^\n]+)? # End of line [ ]* \n @@ -2582,6 +2582,12 @@ class MarkdownExtra_Parser extends Markdown_Parser { function _doFencedCodeBlocks_callback($matches) { $codeblock = $matches[3]; $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES); + /* + Newlines must be replaced with
's because otherwise extra tabs and spaces will + be shown depending on where the Markdown'ed content appears in the HTML source. This + ensures that code blocks are only a single line in the HTML source and no extra + spaces can appear. + */ $codeblock = preg_replace_callback('/\n+/', array(&$this, '_doFencedCodeBlocks_newlines'), $codeblock); $class = ! empty($matches[2]) ? $matches[2] : ( ! empty($matches[4]) ? $matches[4] : '');