From 6508d983228ea33075afabe6d91ceceac8a9cf9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Tue, 13 Jun 2017 23:17:33 +0200 Subject: [PATCH] Add an option to enforce the space when converting atx-style headers --- Michelf/MarkdownExtra.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Michelf/MarkdownExtra.php b/Michelf/MarkdownExtra.php index 7f0f1ff..3236804 100644 --- a/Michelf/MarkdownExtra.php +++ b/Michelf/MarkdownExtra.php @@ -73,6 +73,12 @@ class MarkdownExtra extends \Michelf\Markdown { */ public $predef_abbr = array(); + /** + * Only convert atx-style headers if there's a space between the header and # + * @var boolean + */ + public $enforce_space_atx_style_headers = false; + /** * Parser implementation */ @@ -1042,7 +1048,7 @@ class MarkdownExtra extends \Michelf\Markdown { // $text = preg_replace_callback('{ ^(\#{1,6}) # $1 = string of #\'s - [ ]* + [ ]'.($this->enforce_space_atx_style_headers ? '+' : '*').' (.+?) # $2 = Header text [ ]* \#* # optional closing #\'s (not counted)