X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/140658bc51338b8d1c74382bbf374ad77f07c269..913b2fc3dcc699c7bb25e21652057664dbc90bcc:/IkiWiki/Render.pm diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 886a30f6b..d4e498188 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -29,12 +29,10 @@ sub htmlize ($$) { #{{{ $blosxom::version="is a proper perl module too much to ask?"; use warnings 'all'; do "/usr/bin/markdown"; - require Encode; + use Encode; } if ($type eq '.mdwn') { - # Markdown does character based stuff that does not work - # well with utf-8 strings. $content=Encode::decode_utf8(Markdown::Markdown(Encode::encode_utf8($content))); } else { @@ -95,9 +93,10 @@ sub parentlinks ($) { #{{{ return @ret; } #}}} -sub preprocess ($$) { #{{{ +sub preprocess ($$;$) { #{{{ my $page=shift; my $content=shift; + my $onlystrip=shift || 0; # strip directives without processing my $handle=sub { my $escape=shift; @@ -106,12 +105,17 @@ sub preprocess ($$) { #{{{ if (length $escape) { return "[[$command $params]]"; } + elsif ($onlystrip) { + return ""; + } elsif (exists $hooks{preprocess}{$command}) { - my %params; - while ($params =~ /(\w+)=\"([^"]+)"(\s+|$)/g) { - $params{$1}=$2; + # Note: preserve order of params, some plugins may + # consider it significant. + my @params; + while ($params =~ /(\w+)=\"?([^"]+)"?(\s+|$)/g) { + push @params, $1, $2; } - return $hooks{preprocess}{$command}{call}->(page => $page, %params); + return $hooks{preprocess}{$command}{call}->(@params, page => $page); } else { return "[[$command not processed]]"; @@ -190,12 +194,6 @@ sub genpage ($$$) { #{{{ $template->param(have_actions => 1); } - if (exists $hooks{pagetemplate}) { - foreach my $id (keys %{$hooks{pagetemplate}}) { - $hooks{pagetemplate}{$id}{call}->($page, $template); - } - } - $template->param( title => $title, wikiname => $config{wikiname}, @@ -205,6 +203,12 @@ sub genpage ($$$) { #{{{ mtime => displaytime($mtime), styleurl => styleurl($page), ); + + if (exists $hooks{pagetemplate}) { + foreach my $id (keys %{$hooks{pagetemplate}}) { + $hooks{pagetemplate}{$id}{call}->($page, $template); + } + } return $template->output; } #}}}