mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Enable #hashtag support via setting
This commit is contained in:
parent
8a90586218
commit
d0279cdd3b
11
Parsedown.php
Normal file → Executable file
11
Parsedown.php
Normal file → Executable file
@ -90,6 +90,15 @@ class Parsedown
|
|||||||
|
|
||||||
protected $safeMode;
|
protected $safeMode;
|
||||||
|
|
||||||
|
function setHastagsEnabled($hashtagsEnabled)
|
||||||
|
{
|
||||||
|
$this->hashtagsEnabled = (bool) $hashtagsEnabled;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected $hashtagsEnabled;
|
||||||
|
|
||||||
protected $safeLinksWhitelist = array(
|
protected $safeLinksWhitelist = array(
|
||||||
'http://',
|
'http://',
|
||||||
'https://',
|
'https://',
|
||||||
@ -520,7 +529,7 @@ class Parsedown
|
|||||||
|
|
||||||
$text = trim($Line['text'], '#');
|
$text = trim($Line['text'], '#');
|
||||||
|
|
||||||
if (!isset($text[0]) or $text[0] !== ' ') {
|
if ($this->hashtagsEnabled and (!isset($text[0]) or $text[0] !== ' ')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1
test/ParsedownTest.php
Normal file → Executable file
1
test/ParsedownTest.php
Normal file → Executable file
@ -32,6 +32,7 @@ class ParsedownTest extends TestCase
|
|||||||
protected function initParsedown()
|
protected function initParsedown()
|
||||||
{
|
{
|
||||||
$Parsedown = new TestParsedown();
|
$Parsedown = new TestParsedown();
|
||||||
|
$Parsedown->setHastagsEnabled(true);
|
||||||
|
|
||||||
return $Parsedown;
|
return $Parsedown;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user