From 87806bd01531297a6f1b6ff552db493d3bed4f4c Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Thu, 13 Mar 2014 19:45:43 +0100 Subject: [PATCH] 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. --- src/CustomMarkdown.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CustomMarkdown.php b/src/CustomMarkdown.php index ee331dd9..22e82da8 100644 --- a/src/CustomMarkdown.php +++ b/src/CustomMarkdown.php @@ -28,11 +28,11 @@ class CustomMarkdown extends \Michelf\MarkdownExtra } //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); - $text = preg_replace_callback('{^(\#{1,6})[ ]+(.+?)[ ]*\#*\n+}xm', [&$this, '_doHeaders_callback_atx'], $text); - return $text; + if (!preg_match('/^#+\s/', $matches[0])) + return $matches[0]; + return parent::_doHeaders_callback_atx($matches); } //disable paragraph forming when using simple markdown