]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/linkify.t
linkify: implement Markdown link compatibility (again)
[public-inbox.git] / t / linkify.t
index 49cbbd64edf5d18ca1892f91abd111afed88407e..99acf17d593830884b1533452bf2ceae9ef8cd28 100644 (file)
@@ -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();