From 8a9058621824ff0a675a735fbbf1c1161d596208 Mon Sep 17 00:00:00 2001 From: Nathan Baulch Date: Thu, 29 Mar 2018 22:10:30 +1100 Subject: [PATCH] Support #hashtag per CommonMark and GFM specs --- Parsedown.php | 5 +++++ test/data/atx_heading.html | 4 +++- test/data/atx_heading.md | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index 382023c..1578815 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -519,6 +519,11 @@ class Parsedown } $text = trim($Line['text'], '#'); + + if (!isset($text[0]) or $text[0] !== ' ') { + return; + } + $text = trim($text, ' '); $Block = array( diff --git a/test/data/atx_heading.html b/test/data/atx_heading.html index 94c3825..545d889 100644 --- a/test/data/atx_heading.html +++ b/test/data/atx_heading.html @@ -7,5 +7,7 @@

####### not a heading

closed h1

#

+

##

# of levels

-

# of levels #

\ No newline at end of file +

# of levels #

+

#hashtag

\ No newline at end of file diff --git a/test/data/atx_heading.md b/test/data/atx_heading.md index 62fdd6c..7748aa9 100644 --- a/test/data/atx_heading.md +++ b/test/data/atx_heading.md @@ -16,6 +16,10 @@ # +## + # # of levels -# # of levels # # \ No newline at end of file +# # of levels # # + +#hashtag \ No newline at end of file