X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/628e2ad5e0d0682b401d8ad484e9baeeda4accf8..c1160151d354b7f46cafcf0e5e10402322d44e58:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index e86581415..c2c3aac83 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -3,6 +3,8 @@ package IkiWiki; use warnings; use strict; +use Encode; +use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %oldpagemtime %pagectime %renderedfiles %pagesources %depends %hooks}; @@ -40,7 +42,7 @@ sub defaultconfig () { #{{{ setup => undef, adminuser => undef, adminemail => undef, - plugin => [qw{inline htmlscrubber}], + plugin => [qw{mdwn inline htmlscrubber}], timeformat => '%c', } #}}} @@ -121,12 +123,10 @@ sub dirname ($) { #{{{ sub pagetype ($) { #{{{ my $page=shift; - if ($page =~ /\.mdwn$/) { - return ".mdwn"; - } - else { - return "unknown"; + if ($page =~ /\.(.*)$/) { + return $1 if exists $hooks{htmlize}{$1}; } + return undef; } #}}} sub pagename ($) { #{{{ @@ -134,7 +134,7 @@ sub pagename ($) { #{{{ my $type=pagetype($file); my $page=$file; - $page=~s/\Q$type\E*$// unless $type eq 'unknown'; + $page=~s/\Q.$type\E*$// if defined $type; return $page; } #}}} @@ -162,12 +162,7 @@ sub readfile ($;$) { #{{{ local $/=undef; open (IN, $file) || error("failed to read $file: $!"); - if (! $binary) { - binmode(IN, ":utf8"); - } - else { - binmode(IN); - } + binmode(IN) if ($binary); my $ret=; close IN; return $ret; @@ -199,12 +194,7 @@ sub writefile ($$$;$) { #{{{ } open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!"); - if (! $binary) { - binmode(OUT, ":utf8"); - } - else { - binmode(OUT); - } + binmode(OUT) if ($binary); print OUT $content; close OUT; } #}}} @@ -392,7 +382,6 @@ sub saveindex () { #{{{ sub template_params (@) { #{{{ my $filename=shift; - require Encode; require HTML::Template; return filter => sub { my $text_ref = shift;