1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Rename hashtags enabled to strict mode

We can use this to seperate any intentional spec deviations from
spec behaviour so users can pick between compatability and spec
implementations
This commit is contained in:
Aidan Woods 2018-04-02 17:06:31 +01:00
parent d0279cdd3b
commit cf6d23de55
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
6 changed files with 46 additions and 10 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -7,7 +7,6 @@
<p>####### not a heading</p>
<h1>closed h1</h1>
<p>#</p>
<p>##</p>
<h1># of levels</h1>
<h1># of levels #</h1>
<p>#hashtag</p>
<h1>heading</h1>

View File

@ -16,10 +16,8 @@
#
##
# # of levels
# # of levels # #
#hashtag
#heading

View File

@ -0,0 +1,13 @@
<h1>h1</h1>
<h2>h2</h2>
<h3>h3</h3>
<h4>h4</h4>
<h5>h5</h5>
<h6>h6</h6>
<p>####### not a heading</p>
<p>#not a heading</p>
<h1>closed h1</h1>
<h1></h1>
<h2></h2>
<h1># of levels</h1>
<h1># of levels #</h1>

View File

@ -0,0 +1,25 @@
# h1
## h2
### h3
#### h4
##### h5
###### h6
####### not a heading
#not a heading
# closed h1 #
#
##
# # of levels
# # of levels # #