use warnings;
use strict;
use IkiWiki 3.00;
+use Encode;
# locations of highlight's files
my $filetypes="/etc/highlight/filetypes.conf";
plugin => {
safe => 1,
rebuild => 1, # format plugin
+ section => "format",
},
tohighlight => {
type => "string",
return;
}
- return highlight($langfile, shift);
+ return Encode::decode_utf8(highlight($langfile, shift));
}
my %ext2lang;
# 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\((.*)\)=(.*)$/) {
$gen = highlightc::CodeGenerator_getInstance($highlightc::XHTML);
$gen->setFragmentCode(1); # generate html fragment
$gen->setHTMLEnclosePreTag(1); # include stylish <pre>
- $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;
}