diff options
author | Eric Wong <e@80x24.org> | 2016-12-06 23:40:33 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-12-06 23:40:57 +0000 |
commit | f99f9048cdac42509fbbc1f97e2af32fa3bffca6 (patch) | |
tree | f7960502ba4334dfb01163d7b1bb604ae8ba9ec6 /t | |
parent | 52e44dc8f9e01678f309818c8ca2bc65b8285738 (diff) | |
download | public-inbox-f99f9048cdac42509fbbc1f97e2af32fa3bffca6.tar.gz |
Although unescaped parentheses in URLs are technically allowed, they are uncommon. However, Markdown-like syntaxes are unfortunately common for URLs, so we might as well support them. This fixes parentheses detection at sentence endings, as seen in practice on emails.
Diffstat (limited to 't')
-rw-r--r-- | t/linkify.t | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/t/linkify.t b/t/linkify.t index 49cbbd64..99acf17d 100644 --- a/t/linkify.t +++ b/t/linkify.t @@ -57,4 +57,26 @@ use PublicInbox::Linkify; is($s, qq(hello <a\nhref="$u">$u</a> world), "root + fragment"); } +# Markdown compatibility +{ + my $l = PublicInbox::Linkify->new; + my $u = 'http://example.com/'; + my $s = "[markdown]($u)"; + $s = $l->linkify_1($s); + $s = $l->linkify_2($s); + is($s, qq![markdown](<a\nhref="$u">$u</a>)!, 'Markdown-compatible'); + + $s = qq![markdown]($u "title")!; + $s = $l->linkify_1($s); + $s = $l->linkify_2($s); + is($s, qq![markdown](<a\nhref="$u">$u</a> "title")!, + 'Markdown title compatible'); + + $s = qq![markdown]($u).!; + $s = $l->linkify_1($s); + $s = $l->linkify_2($s); + is($s, qq![markdown](<a\nhref="$u">$u</a>).!, + 'Markdown-compatible end of sentence'); +} + done_testing(); |