Browse code

Add utf-8 encoding option to Pygments highlighter, fixes #232

Frederic Hemberger authored on 21/10/2011 at 07:23:56
Showing 1 changed files
... ...
@@ -21,11 +21,11 @@ module HighlightCode
21 21
       if File.exist?(path)
22 22
         highlighted_code = File.read(path)
23 23
       else
24
-        highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html')
24
+        highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
25 25
         File.open(path, 'w') {|f| f.print(highlighted_code) }
26 26
       end
27 27
     else
28
-      highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html')
28
+      highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
29 29
     end
30 30
     highlighted_code
31 31
   end