]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - t/mdwn.t
Need <sys/wait.h> for waitpid (NetBSD 8 warns).
[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"];
12 IkiWiki::loadplugins();
13 IkiWiki::checkconfig();
15 is(IkiWiki::htmlize("foo", "foo", "mdwn",
16         "C. S. Lewis wrote books\n"),
17         "<p>C. S. Lewis wrote books</p>\n", "alphalist off by default");
19 $config{mdwn_alpha_lists} = 1;
20 like(IkiWiki::htmlize("foo", "foo", "mdwn",
21         "A. One\n".
22         "B. Two\n"),
23         qr{<ol\W}, "alphalist can be enabled");
25 $config{mdwn_alpha_lists} = 0;
26 like(IkiWiki::htmlize("foo", "foo", "mdwn",
27         "A. One\n".
28         "B. Two\n"),
29         qr{<p>A. One\sB. Two</p>\n}, "alphalist can be disabled");
31 like(IkiWiki::htmlize("foo", "foo", "mdwn",
32         "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
33         qr{<p>This works<sup\W}, "footnotes on by default");
35 $config{mdwn_footnotes} = 0;
36 like(IkiWiki::htmlize("foo", "foo", "mdwn",
37         "An unusual link label: [^1]\n\n[^1]: http://example.com/\n"),
38         qr{<a href="http://example\.com/">\^1</a>}, "footnotes can be disabled");
40 $config{mdwn_footnotes} = 1;
41 like(IkiWiki::htmlize("foo", "foo", "mdwn",
42         "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
43         qr{<p>This works<sup\W}, "footnotes can be enabled");
45 SKIP: {
46         skip 'set $IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT if you have Discount 2.2.0+', 4
47                 unless $ENV{IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT};
48         like(IkiWiki::htmlize("foo", "foo", "mdwn",
49                         "Definition list\n: A useful HTML structure\n"),
50                 qr{<dl>.*<dt>Definition list</dt>\s*<dd>A useful HTML structure</dd>}s,
51                 "definition lists are enabled by default");
52         like(IkiWiki::htmlize("foo", "foo", "mdwn",
53                         "```\n#!/bin/sh\n```\n"),
54                 qr{<pre>\s*<code>\s*[#]!/bin/sh\s*</code>\s*</pre>}s,
55                 "code blocks are enabled by default");
56         like(IkiWiki::htmlize("foo", "foo", "mdwn",
57                         "<foo_bar>"),
58                 qr{<foo_bar>},
59                 "GitHub tag name extensions are enabled by default");
60         like(IkiWiki::htmlize("foo", "foo", "mdwn",
61                         "<style>foo</style>"),
62                 qr{<style>foo</style>},
63                 "Styles are not stripped by default");
64 }
66 done_testing();