mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
improve consistency
This commit is contained in:
parent
e0965ce09b
commit
59c77e706b
@ -59,11 +59,6 @@ class Parsedown
|
|||||||
|
|
||||||
private $breaksEnabled;
|
private $breaksEnabled;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var boolean If true HTML is escaped
|
|
||||||
*/
|
|
||||||
private $noMarkup = false;
|
|
||||||
|
|
||||||
function setBreaksEnabled($breaksEnabled)
|
function setBreaksEnabled($breaksEnabled)
|
||||||
{
|
{
|
||||||
$this->breaksEnabled = $breaksEnabled;
|
$this->breaksEnabled = $breaksEnabled;
|
||||||
@ -71,15 +66,11 @@ class Parsedown
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private $markupEscaped;
|
||||||
* Set the `noMarkup` option
|
|
||||||
*
|
function setMarkupEscaped($markupEscaped)
|
||||||
* @param boolean $noMarkup If true HTML is escaped
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
function setNoMarkup($noMarkup)
|
|
||||||
{
|
{
|
||||||
$this->noMarkup = (bool) $noMarkup;
|
$this->markupEscaped = $markupEscaped;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -637,9 +628,9 @@ class Parsedown
|
|||||||
|
|
||||||
protected function identifyMarkup($Line)
|
protected function identifyMarkup($Line)
|
||||||
{
|
{
|
||||||
if ($this->noMarkup)
|
if ($this->markupEscaped)
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^<(\w[\w\d]*)(?:[ ][^>]*)?(\/?)[ ]*>/', $Line['text'], $matches))
|
if (preg_match('/^<(\w[\w\d]*)(?:[ ][^>]*)?(\/?)[ ]*>/', $Line['text'], $matches))
|
||||||
@ -1167,9 +1158,9 @@ class Parsedown
|
|||||||
|
|
||||||
protected function identifyTag($Excerpt)
|
protected function identifyTag($Excerpt)
|
||||||
{
|
{
|
||||||
if ($this->noMarkup)
|
if ($this->markupEscaped)
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<\/?\w.*?>/', $Excerpt['text'], $matches))
|
if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<\/?\w.*?>/', $Excerpt['text'], $matches))
|
||||||
|
@ -101,7 +101,7 @@ MARKDOWN_WITH_MARKUP;
|
|||||||
<p></style></p>
|
<p></style></p>
|
||||||
EXPECTED_HTML;
|
EXPECTED_HTML;
|
||||||
$parsedownWithNoMarkup = new Parsedown();
|
$parsedownWithNoMarkup = new Parsedown();
|
||||||
$parsedownWithNoMarkup->setNoMarkup(true);
|
$parsedownWithNoMarkup->setMarkupEscaped(true);
|
||||||
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
|
$this->assertEquals($expectedHtml, $parsedownWithNoMarkup->text($markdownWithHtml));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user