]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/linkify.t
linkify: handle URLs in parenthesized statements
[public-inbox.git] / t / linkify.t
index a794c785221e3349790528b8e3c69f706cf9d757..041c15c73144efcd8c966ce08f71f7ed10c9e94f 100644 (file)
@@ -14,6 +14,16 @@ use PublicInbox::Linkify;
        is($s, qq(<a\nhref="$u">$u</a>.), 'trailing period not in URL');
 }
 
+# handle URLs in parenthesized statements
+{
+       my $l = PublicInbox::Linkify->new;
+       my $u = 'http://example.com/';
+       my $s = "(see: $u)";
+       $s = $l->linkify_1($s);
+       $s = $l->linkify_2($s);
+       is($s, qq{(see: <a\nhref="$u">$u</a>)}, 'trailing ) not in URL');
+}
+
 {
        my $l = PublicInbox::Linkify->new;
        my $u = 'http://example.com/url-with-trailing-semicolon';
@@ -57,13 +67,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');
+       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();