pygments / pygments.rb

💎 Ruby wrapper for Pygments syntax highlighter
MIT License
572 stars 141 forks source link

Encoding error #20

Closed fnando closed 12 years ago

fnando commented 12 years ago

pygments.rb is not respecting characters while converting code.

# -*- encoding: utf-8 -*-
require "pygments"
puts Pygments.highlight("puts 'áéíóú'", :lexer => "ruby")

Here's the current output:

<div class="highlight"><pre><span class="nb">puts</span> <span class="s1">&#39;áéíóú&#39;</span>
    </pre>
    </div>

The expected output is:

<div class="highlight"><pre><span class="nb">puts</span> <span class="s1">&#39;áéíóú&#39;</span>
    </pre>
    </div>
vmg commented 12 years ago

Try with:

Pygments.highlight(code, :lexer => lang, :options => {:encoding => 'utf-8'})

...or whatever your text encoding is. Cheerios.

fnando commented 12 years ago

Just tried the shell pygmentize command, and everything works as expected.

pygmentize -l ruby -f html -o /tmp/output.html /tmp/chars.rb

fnando commented 12 years ago

@tanoku Oh, thanks! I commented before viewing your post! ;)

vmg commented 12 years ago

:sparkles: