Skip to content

Commit

Permalink
A single place does not replace another tag. Closes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Siewertsen committed Aug 19, 2021
1 parent 0a1a634 commit 41a59d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Markdown/AddCustomHtmlClasses.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private function defineRegexPattern(Tag $tag): string
$pattern .= "<{$name}[^>]*>[^<]*";
}

return "/({$pattern})(<{$tag->tag})(?! class)/iU";
return "/({$pattern})(<{$tag->tag})(?! class|\w)/iU";
}

/**
Expand Down
28 changes: 28 additions & 0 deletions tests/Unit/CommonMarkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,34 @@ public function a_nested_tag_will_be_replaced_and_wont_be_overwritten()
$this->assertEquals($result, Markdown::parse($toParse));
}

/** @test */
public function a_single_tag_will_not_replace_another_tag()
{
config()->set('markdown.styles.default', [
'p' => 'p-3',
'pre' => 'mb-4',
]);

$toParse = <<<'EOT'
<p>
<pre>
<code>Amazing code</code>
</pre>
</p>
EOT;

$result = <<<'EOT'
<p class="p-3">
<pre class="mb-4">
<code>Amazing code</code>
</pre>
</p>

EOT;

$this->assertEquals($result, Markdown::parse($toParse));
}

/** @test */
public function it_prefixes_relative_image_sources()
{
Expand Down

0 comments on commit 41a59d1

Please sign in to comment.