1
0
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:
Nathan Baulch 2018-03-30 03:44:47 +11:00 committed by Aidan Woods
parent 8a90586218
commit d0279cdd3b
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
2 changed files with 11 additions and 1 deletions

11
Parsedown.php Normal file → Executable file
View 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
View 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;
} }