aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2018-03-08 23:36:31 +0000
committerSimon McVittie <smcv@debian.org>2018-03-08 23:36:31 +0000
commite3279c8b508ce88ea2b23f99a1d8a4295fb06dd9 (patch)
treeb68ba1a8acf11ae12234962ec666d1bab4853a26 /t
parent06953a196a200441bfc6e9a9942231b03b23537f (diff)
downloadikiwiki-e3279c8b508ce88ea2b23f99a1d8a4295fb06dd9.tar
ikiwiki-e3279c8b508ce88ea2b23f99a1d8a4295fb06dd9.tar.gz
mdwn: Automatically detect which libdiscount flags to use
Unconditionally passing arbitrary numbers as flags turns out to be a bad idea, because some of the "unused" values have historically had side-effects internal to libdiscount. Detect whether the known flags work by rendering short Markdown snippets the first time we htmlize, checking whether each known flag is both necessary and sufficient. Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 't')
-rwxr-xr-xt/mdwn.t22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/mdwn.t b/t/mdwn.t
index 93b8bd8e9..ca3180139 100755
--- a/t/mdwn.t
+++ b/t/mdwn.t
@@ -8,6 +8,7 @@ BEGIN { use_ok("IkiWiki"); }
%config=IkiWiki::defaultconfig();
$config{srcdir}=$config{destdir}="/dev/null";
+$config{disable_plugins}=["htmlscrubber"];
IkiWiki::loadplugins();
IkiWiki::checkconfig();
@@ -41,4 +42,25 @@ like(IkiWiki::htmlize("foo", "foo", "mdwn",
"This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
qr{<p>This works<sup\W}, "footnotes can be enabled");
+SKIP: {
+ skip 'set $IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT if you have Discount 2.2.0+', 4
+ unless $ENV{IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT};
+ like(IkiWiki::htmlize("foo", "foo", "mdwn",
+ "Definition list\n: A useful HTML structure\n"),
+ qr{<dl>.*<dt>Definition list</dt>\s*<dd>A useful HTML structure</dd>}s,
+ "definition lists are enabled by default");
+ like(IkiWiki::htmlize("foo", "foo", "mdwn",
+ "```\n#!/bin/sh\n```\n"),
+ qr{<pre>\s*<code>\s*[#]!/bin/sh\s*</code>\s*</pre>}s,
+ "code blocks are enabled by default");
+ like(IkiWiki::htmlize("foo", "foo", "mdwn",
+ "<foo_bar>"),
+ qr{<foo_bar>},
+ "GitHub tag name extensions are enabled by default");
+ like(IkiWiki::htmlize("foo", "foo", "mdwn",
+ "<style>foo</style>"),
+ qr{<style>foo</style>},
+ "Styles are not stripped by default");
+}
+
done_testing();