Fixed ATX style header parsing

Markdown Extra that we recently switched to has different implementation from
Markdown (including, but not limited to, regexes), so some of the overwritten
callbacks stopped working.
This commit is contained in:
Marcin Kurczewski 2014-03-13 19:45:43 +01:00
parent 73fc1830ff
commit 87806bd015

View file

@ -28,11 +28,11 @@ class CustomMarkdown extends \Michelf\MarkdownExtra
} }
//make atx-style headers require space after hash //make atx-style headers require space after hash
protected function doHeaders($text) protected function _doHeaders_callback_atx($matches)
{ {
$text = preg_replace_callback('{ ^(.+?)[ ]*\n(=+|-+)[ ]*\n+ }mx', [&$this, '_doHeaders_callback_setext'], $text); if (!preg_match('/^#+\s/', $matches[0]))
$text = preg_replace_callback('{^(\#{1,6})[ ]+(.+?)[ ]*\#*\n+}xm', [&$this, '_doHeaders_callback_atx'], $text); return $matches[0];
return $text; return parent::_doHeaders_callback_atx($matches);
} }
//disable paragraph forming when using simple markdown //disable paragraph forming when using simple markdown