]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/highlight.pm
catch failure to open the filetypes file
[ikiwiki.git] / IkiWiki / Plugin / highlight.pm
index 20f79ef575189506fe5343d31950a3f1a57f961e..e517ac5c06aa425771dcac7256a8e3127da8d3bb 100644 (file)
@@ -4,6 +4,7 @@ package IkiWiki::Plugin::highlight;
 use warnings;
 use strict;
 use IkiWiki 3.00;
+use Encode;
 
 # locations of highlight's files
 my $filetypes="/etc/highlight/filetypes.conf";
@@ -22,6 +23,7 @@ sub getsetup () {
                plugin => {
                        safe => 1,
                        rebuild => 1, # format plugin
+                       section => "format",
                },
                tohighlight => {
                        type => "string",
@@ -69,7 +71,7 @@ sub htmlizefallback {
                return;
        }
 
-       return highlight($langfile, shift);
+       return Encode::decode_utf8(highlight($langfile, shift));
 }
 
 my %ext2lang;
@@ -78,7 +80,7 @@ my %highlighters;
 
 # Parse highlight's config file to get extension => language mappings.
 sub read_filetypes () {
-       open (IN, $filetypes);
+       open (IN, $filetypes) || error("$filetypes: $!");
        while (<IN>) {
                chomp;
                if (/^\$ext\((.*)\)=(.*)$/) {