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

Better name for testing safe mode and strict mode state

Add a nice named constructor
This commit is contained in:
Aidan Woods
2019-01-22 21:19:26 +00:00
parent bb424e606f
commit 3d41f270c2
9 changed files with 22 additions and 8 deletions

View File

@@ -78,7 +78,7 @@ final class Comment implements ContinuableBlock
return new Handler(
/** @return Text|RawHtml */
function (State $State) {
if ($State->getOrDefault(SafeMode::class)->enabled()) {
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
return new Text($this->html);
} else {
return new RawHtml($this->html);

View File

@@ -56,7 +56,7 @@ final class Header implements Block
$StrictMode = $State->getOrDefault(StrictMode::class);
if ($StrictMode->enabled() && isset($text[0]) and $text[0] !== ' ') {
if ($StrictMode->isEnabled() && isset($text[0]) and $text[0] !== ' ') {
return null;
}

View File

@@ -78,7 +78,7 @@ final class Markup implements ContinuableBlock
function (State $State) {
$SafeMode = $State->getOrDefault(SafeMode::class);
if ($SafeMode->enabled()) {
if ($SafeMode->isEnabled()) {
return new Element('p', [], [new Text($this->html)]);
} else {
return new RawHtml($this->html);

View File

@@ -83,7 +83,7 @@ final class Image implements Inline
$attributes['title'] = $title;
}
if ($State->getOrDefault(SafeMode::class)->enabled()) {
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
$attributes['src'] = Element::filterUnsafeUrl($attributes['src']);
}

View File

@@ -122,7 +122,7 @@ final class Link implements Inline
$attributes['title'] = $this->title;
}
if ($State->getOrDefault(SafeMode::class)->enabled()) {
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
$attributes['href'] = Element::filterUnsafeUrl($attributes['href']);
}

View File

@@ -66,7 +66,7 @@ final class Markup implements Inline
function (State $State) {
$SafeMode = $State->getOrDefault(SafeMode::class);
if ($SafeMode->enabled()) {
if ($SafeMode->isEnabled()) {
return new Text($this->html);
} else {
return new RawHtml($this->html);