From e3279c8b508ce88ea2b23f99a1d8a4295fb06dd9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 8 Mar 2018 23:36:31 +0000 Subject: 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 --- t/mdwn.t | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 't') 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{

This works.*

Definition list
\s*
A useful HTML structure
}s, + "definition lists are enabled by default"); + like(IkiWiki::htmlize("foo", "foo", "mdwn", + "```\n#!/bin/sh\n```\n"), + qr{
\s*\s*[#]!/bin/sh\s*\s*
}s, + "code blocks are enabled by default"); + like(IkiWiki::htmlize("foo", "foo", "mdwn", + ""), + qr{}, + "GitHub tag name extensions are enabled by default"); + like(IkiWiki::htmlize("foo", "foo", "mdwn", + ""), + qr{}, + "Styles are not stripped by default"); +} + done_testing(); -- cgit v1.2.3