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:
parent
d0279cdd3b
commit
cf6d23de55
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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>
|
@ -16,10 +16,8 @@
|
||||
|
||||
#
|
||||
|
||||
##
|
||||
|
||||
# # of levels
|
||||
|
||||
# # of levels # #
|
||||
|
||||
#hashtag
|
||||
#heading
|
13
test/data/strict_atx_heading.html
Normal file
13
test/data/strict_atx_heading.html
Normal 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>
|
25
test/data/strict_atx_heading.md
Normal file
25
test/data/strict_atx_heading.md
Normal file
@ -0,0 +1,25 @@
|
||||
# h1
|
||||
|
||||
## h2
|
||||
|
||||
### h3
|
||||
|
||||
#### h4
|
||||
|
||||
##### h5
|
||||
|
||||
###### h6
|
||||
|
||||
####### not a heading
|
||||
|
||||
#not a heading
|
||||
|
||||
# closed h1 #
|
||||
|
||||
#
|
||||
|
||||
##
|
||||
|
||||
# # of levels
|
||||
|
||||
# # of levels # #
|
Loading…
Reference in New Issue
Block a user