diff options
author | Simon McVittie <smcv@debian.org> | 2017-05-14 18:16:53 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2017-05-14 18:16:53 +0100 |
commit | 4db4e589e4c73f076b666a77b86743695454a3ce (patch) | |
tree | 14436dc88eb75dc528f3ee27f6f5abb9a5634478 /IkiWiki | |
parent | 81c3258269fa53684043ce5b9fd701bb6a381017 (diff) | |
download | ikiwiki-4db4e589e4c73f076b666a77b86743695454a3ce.tar ikiwiki-4db4e589e4c73f076b666a77b86743695454a3ce.tar.gz |
mdwn: Enable footnotes by default when using Discount
A new mdwn_footnotes option can be used to disable footnotes in
MultiMarkdown and Discount.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/mdwn.pm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm index aeb3a3fd7..e142fec46 100644 --- a/IkiWiki/Plugin/mdwn.pm +++ b/IkiWiki/Plugin/mdwn.pm @@ -7,6 +7,7 @@ use strict; use IkiWiki 3.00; sub import { + hook(type => "checkconfig", id => "mdwn", call => \&checkconfig); hook(type => "getsetup", id => "mdwn", call => \&getsetup); hook(type => "htmlize", id => "mdwn", call => \&htmlize, longname => "Markdown"); hook(type => "htmlize", id => "md", call => \&htmlize, longname => "Markdown (popular file extension)", nocreate => 1); @@ -33,6 +34,17 @@ sub getsetup () { safe => 1, rebuild => 1, }, + mdwn_footnotes => { + type => "boolean", + example => 1, + description => "enable footnotes in Markdown (where supported)?", + safe => 1, + rebuild => 1, + }, +} + +sub checkconfig () { + $config{mdwn_footnotes} = 1 unless defined $config{mdwn_footnotes}; } my $markdown_sub; @@ -54,7 +66,13 @@ sub htmlize (@) { } else { $markdown_sub=sub { - Text::MultiMarkdown::markdown(shift, {use_metadata => 0}); + my %flags=( use_metadata => 0 ); + + if ($config{mdwn_footnotes}) { + $flags{disable_footnotes}=1; + } + + Text::MultiMarkdown::markdown(shift, \%flags); } } } @@ -79,6 +97,10 @@ sub htmlize (@) { # Use the typography plugin instead $flags |= Text::Markdown::Discount::MKD_NOPANTS(); + if ($config{mdwn_footnotes}) { + $flags |= Text::Markdown::Discount::MKD_EXTRA_FOOTNOTE(); + } + # Workaround for discount's eliding # of <style> blocks. # https://rt.cpan.org/Ticket/Display.html?id=74016 |