diff --git a/Parsedown.php b/Parsedown.php index ff1ae0e..a3efd7a 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -90,14 +90,14 @@ class Parsedown protected $safeMode; - function setHastagsEnabled($hashtagsEnabled) + function setStrictMode($strictMode) { - $this->hashtagsEnabled = (bool) $hashtagsEnabled; + $this->strictMode = (bool) $strictMode; return $this; } - protected $hashtagsEnabled; + protected $strictMode; protected $safeLinksWhitelist = array( 'http://', @@ -529,7 +529,8 @@ class Parsedown $text = trim($Line['text'], '#'); - if ($this->hashtagsEnabled and (!isset($text[0]) or $text[0] !== ' ')) { + if ($this->strictMode and ( ! isset($text[0]) or $text[0] !== ' ')) + { return; } diff --git a/test/ParsedownTest.php b/test/ParsedownTest.php index f4c5f7c..bf40317 100755 --- a/test/ParsedownTest.php +++ b/test/ParsedownTest.php @@ -32,7 +32,6 @@ class ParsedownTest extends TestCase protected function initParsedown() { $Parsedown = new TestParsedown(); - $Parsedown->setHastagsEnabled(true); return $Parsedown; } @@ -52,6 +51,7 @@ class ParsedownTest extends TestCase $expectedMarkup = str_replace("\r", "\n", $expectedMarkup); $this->Parsedown->setSafeMode(substr($test, 0, 3) === 'xss'); + $this->Parsedown->setStrictMode(substr($test, 0, 6) === 'strict'); $actualMarkup = $this->Parsedown->text($markdown); diff --git a/test/data/atx_heading.html b/test/data/atx_heading.html index 545d889..387e2ec 100644 --- a/test/data/atx_heading.html +++ b/test/data/atx_heading.html @@ -7,7 +7,6 @@

####### not a heading

closed h1

#

-

##

# of levels

# of levels #

-

#hashtag

\ No newline at end of file +

heading

\ No newline at end of file diff --git a/test/data/atx_heading.md b/test/data/atx_heading.md index 7748aa9..3724c1f 100644 --- a/test/data/atx_heading.md +++ b/test/data/atx_heading.md @@ -16,10 +16,8 @@ # -## - # # of levels # # of levels # # -#hashtag \ No newline at end of file +#heading \ No newline at end of file diff --git a/test/data/strict_atx_heading.html b/test/data/strict_atx_heading.html new file mode 100644 index 0000000..11cf4df --- /dev/null +++ b/test/data/strict_atx_heading.html @@ -0,0 +1,13 @@ +

h1

+

h2

+

h3

+

h4

+
h5
+
h6
+

####### not a heading

+

#not a heading

+

closed h1

+

+

+

# of levels

+

# of levels #

\ No newline at end of file diff --git a/test/data/strict_atx_heading.md b/test/data/strict_atx_heading.md new file mode 100644 index 0000000..5358731 --- /dev/null +++ b/test/data/strict_atx_heading.md @@ -0,0 +1,25 @@ +# h1 + +## h2 + +### h3 + +#### h4 + +##### h5 + +###### h6 + +####### not a heading + +#not a heading + +# closed h1 # + +# + +## + +# # of levels + +# # of levels # # \ No newline at end of file