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:
@ -25,6 +25,8 @@
|
|||||||
<referencedMethod name="Erusev\Parsedown\State::get" />
|
<referencedMethod name="Erusev\Parsedown\State::get" />
|
||||||
<referencedMethod name="Erusev\Parsedown\Parsedown::line" />
|
<referencedMethod name="Erusev\Parsedown\Parsedown::line" />
|
||||||
<referencedMethod name="Erusev\Parsedown\Parsing\Lines::last" />
|
<referencedMethod name="Erusev\Parsedown\Parsing\Lines::last" />
|
||||||
|
<referencedMethod name="Erusev\Parsedown\Configurables\StrictMode::enabled" />
|
||||||
|
<referencedMethod name="Erusev\Parsedown\Configurables\SafeMode::enabled" />
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</PossiblyUnusedMethod>
|
</PossiblyUnusedMethod>
|
||||||
</issueHandlers>
|
</issueHandlers>
|
||||||
|
@ -78,7 +78,7 @@ final class Comment implements ContinuableBlock
|
|||||||
return new Handler(
|
return new Handler(
|
||||||
/** @return Text|RawHtml */
|
/** @return Text|RawHtml */
|
||||||
function (State $State) {
|
function (State $State) {
|
||||||
if ($State->getOrDefault(SafeMode::class)->enabled()) {
|
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
|
||||||
return new Text($this->html);
|
return new Text($this->html);
|
||||||
} else {
|
} else {
|
||||||
return new RawHtml($this->html);
|
return new RawHtml($this->html);
|
||||||
|
@ -56,7 +56,7 @@ final class Header implements Block
|
|||||||
|
|
||||||
$StrictMode = $State->getOrDefault(StrictMode::class);
|
$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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ final class Markup implements ContinuableBlock
|
|||||||
function (State $State) {
|
function (State $State) {
|
||||||
$SafeMode = $State->getOrDefault(SafeMode::class);
|
$SafeMode = $State->getOrDefault(SafeMode::class);
|
||||||
|
|
||||||
if ($SafeMode->enabled()) {
|
if ($SafeMode->isEnabled()) {
|
||||||
return new Element('p', [], [new Text($this->html)]);
|
return new Element('p', [], [new Text($this->html)]);
|
||||||
} else {
|
} else {
|
||||||
return new RawHtml($this->html);
|
return new RawHtml($this->html);
|
||||||
|
@ -83,7 +83,7 @@ final class Image implements Inline
|
|||||||
$attributes['title'] = $title;
|
$attributes['title'] = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($State->getOrDefault(SafeMode::class)->enabled()) {
|
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
|
||||||
$attributes['src'] = Element::filterUnsafeUrl($attributes['src']);
|
$attributes['src'] = Element::filterUnsafeUrl($attributes['src']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ final class Link implements Inline
|
|||||||
$attributes['title'] = $this->title;
|
$attributes['title'] = $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($State->getOrDefault(SafeMode::class)->enabled()) {
|
if ($State->getOrDefault(SafeMode::class)->isEnabled()) {
|
||||||
$attributes['href'] = Element::filterUnsafeUrl($attributes['href']);
|
$attributes['href'] = Element::filterUnsafeUrl($attributes['href']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ final class Markup implements Inline
|
|||||||
function (State $State) {
|
function (State $State) {
|
||||||
$SafeMode = $State->getOrDefault(SafeMode::class);
|
$SafeMode = $State->getOrDefault(SafeMode::class);
|
||||||
|
|
||||||
if ($SafeMode->enabled()) {
|
if ($SafeMode->isEnabled()) {
|
||||||
return new Text($this->html);
|
return new Text($this->html);
|
||||||
} else {
|
} else {
|
||||||
return new RawHtml($this->html);
|
return new RawHtml($this->html);
|
||||||
|
@ -18,11 +18,17 @@ final class SafeMode implements Configurable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return bool */
|
/** @return bool */
|
||||||
public function enabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return $this->enabled;
|
return $this->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return self */
|
||||||
|
public static function enabled()
|
||||||
|
{
|
||||||
|
return new self(true);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return self */
|
/** @return self */
|
||||||
public static function initial()
|
public static function initial()
|
||||||
{
|
{
|
||||||
|
@ -18,11 +18,17 @@ final class StrictMode implements Configurable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @return bool */
|
/** @return bool */
|
||||||
public function enabled()
|
public function isEnabled()
|
||||||
{
|
{
|
||||||
return $this->enabled;
|
return $this->enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return self */
|
||||||
|
public static function enabled()
|
||||||
|
{
|
||||||
|
return new self(true);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return self */
|
/** @return self */
|
||||||
public static function initial()
|
public static function initial()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user