Skip to content

Commit

Permalink
fix: link target regex properly catches multiple a elements
Browse files Browse the repository at this point in the history
  • Loading branch information
simonerd committed Jan 18, 2024
1 parent 3b50c25 commit baf88fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function sanitizeContent(string $content): string
if (! $this->withHtmlTags) {
// optionally extract link targets and add them in () behind the link name
if ($this->withLinkTargets) {
$content = preg_replace("/<a (?:.+ )?href=\"([-_.~!*'();:@&=+$,\/?%#[A-z0-9]+)\"(?: .+)?>(.+)<\/a>/", '$2 ($1)', $content);
$content = preg_replace('/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/', '$2 ($1)', $content);
}

// add whitespace between strings within html tags
Expand Down

0 comments on commit baf88fd

Please sign in to comment.