]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/highlight.pm
highlight: Fix utf-8 encoding bug. Closes: #535028
[ikiwiki.git] / IkiWiki / Plugin / highlight.pm
index 4c02f6c236e4feca4f6113e73f793bee683fef2c..9bdde85ae3bfd725ee83265b923eb445021a15c4 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";
@@ -69,7 +70,7 @@ sub htmlizefallback {
                return;
        }
 
-       return highlight($langfile, shift);
+       return Encode::decode_utf8(highlight($langfile, shift));
 }
 
 my %ext2lang;
@@ -128,8 +129,8 @@ sub highlight ($$) {
                $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;
        }