]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/mdwn.t
another example error i get
[git.ikiwiki.info.git] / t / mdwn.t
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Test::More;
5 use Encode;
7 BEGIN { use_ok("IkiWiki"); }
9 %config=IkiWiki::defaultconfig();
10 $config{srcdir}=$config{destdir}="/dev/null";
11 $config{disable_plugins}=["htmlscrubber"];
13 foreach my $multimarkdown (qw(1 0)) {
14         $config{multimarkdown} = $multimarkdown;
15         undef $IkiWiki::Plugin::mdwn::markdown_sub
16                 if defined $IkiWiki::Plugin::mdwn::markdown_sub;
17         IkiWiki::loadplugins();
18         IkiWiki::checkconfig();
20         is(IkiWiki::htmlize("foo", "foo", "mdwn",
21                 "C. S. Lewis wrote books\n"),
22                 "<p>C. S. Lewis wrote books</p>\n",
23                 "alphalist off by default for multimarkdown = $multimarkdown");
25         like(IkiWiki::htmlize("foo", "foo", "mdwn",
26                 "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
27                 qr{<p>This works.*fnref:1.*},
28                 "footnotes on by default for multimarkdown = $multimarkdown");
30         $config{mdwn_footnotes} = 0;
31         unlike(IkiWiki::htmlize("foo", "foo", "mdwn",
32                 "An unusual link label: [^1]\n\n[^1]: http://example.com/\n"),
33                 qr{<p>An unusual link label: .*fnref:1.*},
34                 "footnotes can be disabled for multimarkdown = $multimarkdown");
36         $config{mdwn_footnotes} = 1;
37         like(IkiWiki::htmlize("foo", "foo", "mdwn",
38                 "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
39                 qr{<p>This works.*fnref:1.*},
40                 "footnotes can be enabled for multimarkdown = $multimarkdown");
41 }
43 $config{mdwn_alpha_lists} = 1;
44 like(IkiWiki::htmlize("foo", "foo", "mdwn",
45         "A. One\n".
46         "B. Two\n"),
47         qr{<ol\W}, "alphalist can be enabled");
49 $config{mdwn_alpha_lists} = 0;
50 like(IkiWiki::htmlize("foo", "foo", "mdwn",
51         "A. One\n".
52         "B. Two\n"),
53         qr{<p>A. One\sB. Two</p>\n}, "alphalist can be disabled");
55 SKIP: {
56         skip 'set $IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT if you have Discount 2.2.0+', 4
57                 unless $ENV{IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT};
58         like(IkiWiki::htmlize("foo", "foo", "mdwn",
59                         "Definition list\n: A useful HTML structure\n"),
60                 qr{<dl>.*<dt>Definition list</dt>\s*<dd>A useful HTML structure</dd>}s,
61                 "definition lists are enabled by default");
62         like(IkiWiki::htmlize("foo", "foo", "mdwn",
63                         "```\n#!/bin/sh\n```\n"),
64                 qr{<pre>\s*<code>\s*[#]!/bin/sh\s*</code>\s*</pre>}s,
65                 "code blocks are enabled by default");
66         like(IkiWiki::htmlize("foo", "foo", "mdwn",
67                         "<foo_bar>"),
68                 qr{<foo_bar>},
69                 "GitHub tag name extensions are enabled by default");
70         like(IkiWiki::htmlize("foo", "foo", "mdwn",
71                         "<style>foo</style>"),
72                 qr{<style>foo</style>},
73                 "Styles are not stripped by default");
74 }
76 done_testing();