X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/39e5e250006421535c13b97e9ca28600c8447877..b5e7f7a67f9893c7083afe3594c4a274c1b96062:/IkiWiki/Plugin/highlight.pm diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index 4c02f6c23..e517ac5c0 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -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 () { chomp; if (/^\$ext\((.*)\)=(.*)$/) { @@ -128,8 +130,8 @@ sub highlight ($$) { $gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML); $gen->setFragmentCode(1); # generate html fragment $gen->setHTMLEnclosePreTag(1); # include stylish
-		$gen->initLanguage($langfile);
 		$gen->initTheme("/dev/null"); # theme is not needed because CSS is not emitted
+		$gen->initLanguage($langfile); # must come after initTheme
 		$gen->setEncoding("utf-8");
 		$highlighters{$langfile}=$gen;
 	}