From 0df2ad5dfe1d896520eceabfe362891f68ed3165 Mon Sep 17 00:00:00 2001 From: joey Date: Sat, 16 Sep 2006 01:50:29 +0000 Subject: [PATCH] * Support Text::Markdown from CPAN, which has a different interface from the original markdown or the one in Debian. --- IkiWiki/Plugin/mdwn.pm | 22 ++++++++++++++-------- debian/changelog | 6 +++--- doc/bugs/404_when_cancel_create_page.mdwn | 6 +++--- doc/bugs/markdown_module_location.mdwn | 8 +++++++- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm index 0fc077f5e..c871e2a4d 100644 --- a/IkiWiki/Plugin/mdwn.pm +++ b/IkiWiki/Plugin/mdwn.pm @@ -10,28 +10,34 @@ sub import { #{{{ hook(type => "htmlize", id => "mdwn", call => \&htmlize); } # }}} -my $markdown_loaded=0; +my $markdown_sub; sub htmlize (@) { #{{{ my %params=@_; my $content = $params{content}; - if (! $markdown_loaded) { - # Note: This hack to make markdown run as a proper perl - # module. A proper perl module is available in Debian - # for markdown, but not upstream yet. + if (! defined $markdown_sub) { + # Markdown is forked and splintered upstream and can be + # available in a variety of incompatible forms. Support + # them all. no warnings 'once'; $blosxom::version="is a proper perl module too much to ask?"; use warnings 'all'; eval q{use Markdown}; - if ($@) { + if (! $@) { + $markdown_sub=\&Markdown::Markdown; + } + else { eval q{use Text::Markdown}; - if ($@) { + if (! $@) { + $markdown_sub=\&Text::Markdown::Markdown; + } + else { do "/usr/bin/markdown" || error("failed to load Markdown.pm perl module ($@) or /usr/bin/markdown ($!)"); + $markdown_sub=\&Markdown::Markdown; } } - $markdown_loaded=1; require Encode; } diff --git a/debian/changelog b/debian/changelog index 95838fc6e..62084a675 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,13 +36,13 @@ ikiwiki (1.27) UNRELEASED; urgency=low * pagetemplate hooks are now also called when generating cgi pages. * Add a favicon plugin, which simply adds a link tag for an icon to each page (and cgis). - * Deal with CPAN installing Markdown as Text::Markdown, while it's - installed as just Markdown by apt. * Patch from James Westby to deal with the case where you're editing a new page, hit cancel, and need to be redirected to somewhere sane. * Various documentation improvements by various wiki users. + * Support Text::Markdown from CPAN, which has a different interface from + the original markdown or the one in Debian. - -- Joey Hess Fri, 15 Sep 2006 21:20:31 -0400 + -- Joey Hess Fri, 15 Sep 2006 21:49:23 -0400 ikiwiki (1.26) unstable; urgency=low diff --git a/doc/bugs/404_when_cancel_create_page.mdwn b/doc/bugs/404_when_cancel_create_page.mdwn index 780187d31..acf5ac9b3 100644 --- a/doc/bugs/404_when_cancel_create_page.mdwn +++ b/doc/bugs/404_when_cancel_create_page.mdwn @@ -48,13 +48,13 @@ is there aren't going to be many possible extensions. Something like `/(.\w+)+/` (groups of dot separated alpha-num chars if my perl-foo isn't failing me). You could at least exclude `/` and `..`. I'm happy to turn this in to a patch if you agree.] -> The reason it's safe to use possibly_foolish_untaint here is because +> The reason it's safe to use `possibly_foolish_untaint` here is because > of the check for $hooks{htmlize}{$type}. This limits it to types > that have a registered htmlize hook (mdwn, etc), and not whatever random > garbage an attacker might try to put in. If it wasn't for that check, -> using possibly_foolish_untaint there would be _very_ foolish indeed.. +> using `possibly_foolish_untaint` there would be _very_ foolish indeed.. > --[[Joey]] >> Nice, sorry I missed it. >> I must say thankyou for creating ikiwiki. ->> The more I look at it, the more I admire what you are doing with it and how you are going about it \ No newline at end of file +>> The more I look at it, the more I admire what you are doing with it and how you are going about it diff --git a/doc/bugs/markdown_module_location.mdwn b/doc/bugs/markdown_module_location.mdwn index c42662026..4deaeb19a 100644 --- a/doc/bugs/markdown_module_location.mdwn +++ b/doc/bugs/markdown_module_location.mdwn @@ -23,4 +23,10 @@ doesn't has a Markdown::Markdown. Interesting, I'll have a look at it. --[[Joey]] > It works if you use Text::Markdown::Markdown, sorry, I forgot to mention that. -> --JamesWestby \ No newline at end of file +> --JamesWestby + +I think what I've committed now will work in all cases. Well, unless there +are even more forks of markdown out there (the CPAN module is a fork +apparently...) + +[[bugs/done]] --[[Joey]] -- 2.39.5