From 0b55dfad04e3695b02633ad9d5420bf84fb06272 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 2 Feb 2014 19:23:52 +0100 Subject: [PATCH] Markdown: restored ATX headers See be3b39bf4250a113bda91005b0362c8bc84fe5ab. It works again, but it requires putting a space after hash. --- src/CustomMarkdown.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/CustomMarkdown.php b/src/CustomMarkdown.php index 63082475..fdb3a2aa 100644 --- a/src/CustomMarkdown.php +++ b/src/CustomMarkdown.php @@ -27,10 +27,12 @@ class CustomMarkdown extends \Michelf\Markdown parent::__construct(); } - //disable atx-style headers - protected function _doHeaders_callback_atx($matches) + //make atx-style headers require space after hash + protected function doHeaders($text) { - return $matches[0]; + $text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx', [&$this, '_doHeaders_callback_setext'], $text); + $text = preg_replace_callback('{^(\#{1,6})[ ]+(.+?)[ ]*\#*\n+}xm', [&$this, '_doHeaders_callback_atx'], $text); + return $text; } //disable paragraph forming when using simple markdown @@ -85,7 +87,8 @@ class CustomMarkdown extends \Michelf\Markdown //handle white characters inside code blocks //so that they won't be optimized away by prettifying HTML - protected function _doCodeBlocks_callback($matches) { + protected function _doCodeBlocks_callback($matches) + { $codeblock = $matches[1]; $codeblock = $this->outdent($codeblock);