diff --git a/psalm.xml b/psalm.xml
index 8b58482..d3d69ec 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -30,6 +30,7 @@
+
diff --git a/src/Components/Inlines/Link.php b/src/Components/Inlines/Link.php
index d382bff..ddbfb7d 100644
--- a/src/Components/Inlines/Link.php
+++ b/src/Components/Inlines/Link.php
@@ -6,6 +6,7 @@ use Erusev\Parsedown\AST\Handler;
use Erusev\Parsedown\AST\StateRenderable;
use Erusev\Parsedown\Components\Inline;
use Erusev\Parsedown\Configurables\DefinitionBook;
+use Erusev\Parsedown\Configurables\InlineTypes;
use Erusev\Parsedown\Configurables\SafeMode;
use Erusev\Parsedown\Html\Renderables\Element;
use Erusev\Parsedown\Html\Renderables\Text;
@@ -126,10 +127,14 @@ final class Link implements Inline
$attributes['href'] = Element::filterUnsafeUrl($attributes['href']);
}
+ $NewState = $State->setting(
+ $State->get(InlineTypes::class)->removing([Url::class])
+ );
+
return new Element(
'a',
$attributes,
- $State->applyTo($Parsedown->line($this->label))
+ $State->applyTo((new Parsedown($NewState))->line($this->label))
);
}
);
diff --git a/src/Configurables/BlockTypes.php b/src/Configurables/BlockTypes.php
index cafe0ae..ff5bdff 100644
--- a/src/Configurables/BlockTypes.php
+++ b/src/Configurables/BlockTypes.php
@@ -100,6 +100,27 @@ final class BlockTypes implements Configurable
return new self($this->blockTypes, $newUnmarkedBlockTypes);
}
+ /**
+ * @param class-string[] $removeBlockTypes
+ * @return self
+ */
+ public function removing(array $removeBlockTypes)
+ {
+ return new self(
+ \array_map(
+ /**
+ * @param class-string[] $blockTypes
+ * @return class-string[]
+ */
+ function ($blockTypes) use ($removeBlockTypes) {
+ return \array_diff($blockTypes, $removeBlockTypes);
+ },
+ $this->blockTypes
+ ),
+ \array_diff($this->unmarkedBlockTypes, $removeBlockTypes)
+ );
+ }
+
/**
* @param string $marker
* @return class-string[]
diff --git a/src/Configurables/InlineTypes.php b/src/Configurables/InlineTypes.php
index f056eb3..909908f 100644
--- a/src/Configurables/InlineTypes.php
+++ b/src/Configurables/InlineTypes.php
@@ -59,6 +59,24 @@ final class InlineTypes implements Configurable
return new self(self::$defaultInlineTypes);
}
+ /**
+ * @param class-string[] $removeInlineTypes
+ * @return self
+ */
+ public function removing(array $removeInlineTypes)
+ {
+ return new self(\array_map(
+ /**
+ * @param class-string[] $inlineTypes
+ * @return class-string[]
+ */
+ function ($inlineTypes) use ($removeInlineTypes) {
+ return \array_diff($inlineTypes, $removeInlineTypes);
+ },
+ $this->inlineTypes
+ ));
+ }
+
/**
* @param string $marker
* @return class-string[]
diff --git a/tests/CommonMarkTestStrict.php b/tests/CommonMarkTestStrict.php
index e2201d5..9eab638 100644
--- a/tests/CommonMarkTestStrict.php
+++ b/tests/CommonMarkTestStrict.php
@@ -2,6 +2,8 @@
namespace Erusev\Parsedown\Tests;
+use Erusev\Parsedown\Components\Inlines\Url;
+use Erusev\Parsedown\Configurables\InlineTypes;
use Erusev\Parsedown\Configurables\StrictMode;
use Erusev\Parsedown\Parsedown;
use Erusev\Parsedown\State;
@@ -21,7 +23,8 @@ class CommonMarkTestStrict extends TestCase
protected function setUp()
{
$this->parsedown = new Parsedown(new State([
- StrictMode::enabled()
+ StrictMode::enabled(),
+ InlineTypes::initial()->removing([Url::class]),
]));
// $this->parsedown->setUrlsLinked(false);
}