]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
Fix inverted footnote config with MultiMarkdown.
authorAmitai Schleier <schmonz-web-ikiwiki@schmonz.com>
Wed, 4 Sep 2019 23:01:28 +0000 (19:01 -0400)
committerAmitai Schleier <schmonz-web-ikiwiki@schmonz.com>
Wed, 4 Sep 2019 23:01:28 +0000 (19:01 -0400)
Bug spotted and fix from Giuseppe Bilotta <giuseppe.bilotta@gmail.com>.

Extend mdwn tests to cover MultiMarkdown, where applicable.

IkiWiki/Plugin/mdwn.pm
t/mdwn.t

index eefa29a9711204541c52b2c83fa959103fc05e67..9158a477beb5bdbd98855253a57dafa21ca53fb3 100644 (file)
@@ -56,7 +56,7 @@ sub checkconfig () {
        $config{mdwn_alpha_lists} = 0 unless defined $config{mdwn_alpha_lists};
 }
 
        $config{mdwn_alpha_lists} = 0 unless defined $config{mdwn_alpha_lists};
 }
 
-my $markdown_sub;
+our $markdown_sub;
 sub htmlize (@) {
        my %params=@_;
        my $content = $params{content};
 sub htmlize (@) {
        my %params=@_;
        my $content = $params{content};
@@ -77,9 +77,7 @@ sub htmlize (@) {
                                $markdown_sub=sub {
                                        my %flags=( use_metadata => 0 );
 
                                $markdown_sub=sub {
                                        my %flags=( use_metadata => 0 );
 
-                                       if ($config{mdwn_footnotes}) {
-                                               $flags{disable_footnotes}=1;
-                                       }
+                                       $flags{disable_footnotes}=not $config{mdwn_footnotes};
 
                                        Text::MultiMarkdown::markdown(shift, \%flags);
                                }
 
                                        Text::MultiMarkdown::markdown(shift, \%flags);
                                }
index ca3180139445f7659735e998f9c265b074db4da2..fc11cadae4c74c3e0d52cf6c6e855d65dafdb015 100755 (executable)
--- a/t/mdwn.t
+++ b/t/mdwn.t
@@ -9,12 +9,36 @@ BEGIN { use_ok("IkiWiki"); }
 %config=IkiWiki::defaultconfig();
 $config{srcdir}=$config{destdir}="/dev/null";
 $config{disable_plugins}=["htmlscrubber"];
 %config=IkiWiki::defaultconfig();
 $config{srcdir}=$config{destdir}="/dev/null";
 $config{disable_plugins}=["htmlscrubber"];
-IkiWiki::loadplugins();
-IkiWiki::checkconfig();
 
 
-is(IkiWiki::htmlize("foo", "foo", "mdwn",
-       "C. S. Lewis wrote books\n"),
-       "<p>C. S. Lewis wrote books</p>\n", "alphalist off by default");
+foreach my $multimarkdown (qw(1 0)) {
+       $config{multimarkdown} = $multimarkdown;
+       undef $IkiWiki::Plugin::mdwn::markdown_sub
+               if defined $IkiWiki::Plugin::mdwn::markdown_sub;
+       IkiWiki::loadplugins();
+       IkiWiki::checkconfig();
+
+       is(IkiWiki::htmlize("foo", "foo", "mdwn",
+               "C. S. Lewis wrote books\n"),
+               "<p>C. S. Lewis wrote books</p>\n",
+               "alphalist off by default for multimarkdown = $multimarkdown");
+
+       like(IkiWiki::htmlize("foo", "foo", "mdwn",
+               "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
+               qr{<p>This works.*fnref:1.*},
+               "footnotes on by default for multimarkdown = $multimarkdown");
+
+       $config{mdwn_footnotes} = 0;
+       unlike(IkiWiki::htmlize("foo", "foo", "mdwn",
+               "An unusual link label: [^1]\n\n[^1]: http://example.com/\n"),
+               qr{<p>An unusual link label: .*fnref:1.*},
+               "footnotes can be disabled for multimarkdown = $multimarkdown");
+
+       $config{mdwn_footnotes} = 1;
+       like(IkiWiki::htmlize("foo", "foo", "mdwn",
+               "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
+               qr{<p>This works.*fnref:1.*},
+               "footnotes can be enabled for multimarkdown = $multimarkdown");
+}
 
 $config{mdwn_alpha_lists} = 1;
 like(IkiWiki::htmlize("foo", "foo", "mdwn",
 
 $config{mdwn_alpha_lists} = 1;
 like(IkiWiki::htmlize("foo", "foo", "mdwn",
@@ -28,20 +52,6 @@ like(IkiWiki::htmlize("foo", "foo", "mdwn",
        "B. Two\n"),
        qr{<p>A. One\sB. Two</p>\n}, "alphalist can be disabled");
 
        "B. Two\n"),
        qr{<p>A. One\sB. Two</p>\n}, "alphalist can be disabled");
 
-like(IkiWiki::htmlize("foo", "foo", "mdwn",
-       "This works[^1]\n\n[^1]: Sometimes it doesn't.\n"),
-       qr{<p>This works<sup\W}, "footnotes on by default");
-
-$config{mdwn_footnotes} = 0;
-like(IkiWiki::htmlize("foo", "foo", "mdwn",
-       "An unusual link label: [^1]\n\n[^1]: http://example.com/\n"),
-       qr{<a href="http://example\.com/">\^1</a>}, "footnotes can be disabled");
-
-$config{mdwn_footnotes} = 1;
-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};
 SKIP: {
        skip 'set $IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT if you have Discount 2.2.0+', 4
                unless $ENV{IKIWIKI_TEST_ASSUME_MODERN_DISCOUNT};