my $content=shift;
if (! $INC{"/usr/bin/markdown"}) {
+ # Note: a proper perl module is available in Debian
+ # for markdown, but not upstream yet.
no warnings 'once';
$blosxom::version="is a proper perl module too much to ask?";
use warnings 'all';
}
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)));
+ # Workaround for perl bug (#376329)
+ $content=Encode::encode_utf8($content);
+ $content=Encode::encode_utf8($content);
+ $content=Markdown::Markdown($content);
+ $content=Encode::decode_utf8($content);
+ $content=Encode::decode_utf8($content);
}
else {
error("htmlization of $type not supported");
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;
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]]";
my $title=pagetitle(basename($page));
- my $template=HTML::Template->new(blind_cache => 1,
- filename => "$config{templatedir}/page.tmpl");
+ my $template=template("page.tmpl", blind_cache => 1);
my $actions=0;
if (length $config{cgiurl}) {
$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},
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;
} #}}}
sub displaytime ($) { #{{{
my $time=shift;
- if ($config{timeformat} eq '%c') {
- return scalar(localtime($time)); # optimisation
- }
- else {
- eval q{use POSIX};
- return POSIX::strftime($config{timeformat}, localtime($time));
- }
+ eval q{use POSIX};
+ # strftime doesn't know about encodings, so make sure
+ # its output is properly treated as utf8
+ return Encode::decode_utf8(POSIX::strftime(
+ $config{timeformat}, localtime($time)));
} #}}}
sub mtime ($) { #{{{