4 use Test::More tests => 11;
9 my @existing_pages=@{shift()};
11 # This is what linkify and htmllink need set right now to work.
12 # This could change, if so, update it..
14 foreach my $page (@existing_pages) {
15 $IkiWiki::links{$page}=[];
16 $IkiWiki::renderedfiles{"$page.mdwn"}=$page;
18 %IkiWiki::config=IkiWiki::defaultconfig();
20 return IkiWiki::linkify($content, $page);
27 if ($content =~ m!<a href="[^"]*\Q$link\E[^"]*">!) {
31 print STDERR "# expected link to $link in $content\n";
36 sub not_links_to ($$) {
40 if ($content !~ m!<a href="[^"]*\Q$link\E[^"]*">!) {
44 print STDERR "# expected no link to $link in $content\n";
53 if ($content =~ m!>\Q$text\E</a>!) {
57 print STDERR "# expected link text $text in $content\n";
63 BEGIN { use_ok("IkiWiki::Render"); }
65 ok(links_to("bar", linkify("link to [[bar]] ok", "foo", ["foo", "bar"])), "ok link");
66 ok(not_links_to("bar", linkify("link to \\[[bar]] ok", "foo", ["foo", "bar"])), "escaped link");
67 ok(links_to("page=bar", linkify("link to [[bar]] ok", "foo", ["foo"])), "broken link");
68 ok(links_to("bar", linkify("link to [[baz]] and [[bar]] ok", "foo", ["foo", "baz", "bar"])), "dual links");
69 ok(links_to("baz", linkify("link to [[baz]] and [[bar]] ok", "foo", ["foo", "baz", "bar"])), "dual links");
70 ok(links_to("bar", linkify("link to [[some_page|bar]] ok", "foo", ["foo", "bar"])), "named link");
71 ok(links_text("some page", linkify("link to [[some_page|bar]] ok", "foo", ["foo", "bar"])), "named link text");
72 ok(links_to("bar", linkify("link to [[some page|bar]] ok", "foo", ["foo", "bar"])), "named link, with whitespace");
73 ok(links_text("some page", linkify("link to [[some page|bar]] ok", "foo", ["foo", "bar"])), "named link text, with whitespace");
74 ok(links_text("Some long, & complex page name.", linkify("link to [[Some long, & complex page name.|bar]] ok, and this is not a link]] here", "foo", ["foo", "bar"])), "complex named link text");