I had some trouble getting Jekyll's syntax highlighting working on Arch Linux. Every time I added a code block using the {% highlight %} tag, the contents of the tag would just disappear.
My installation was:
# Install pacgem
$ wget https://aur.archlinux.org/packages/pacgem/pacgem.tar.gz
$ tar xzf pacgem.tar.gz
$ cd pacgem
$ makepkg -s
$ pacman -U pacgem-*.tar.xz
# Install Jekyll
$ pacgem jekyll
# Install Pygments
$ sudo pacman -S python-pygments
Jekyll uses the Albino wrapper for the Python Pygments library to handle syntax highlighting. My first test was to see if Albino was working correctly. I tested it out using the example from the project page:
require 'albino'
puts Albino.colorize('puts "Hello World"', :ruby)
Sure enough, there was no output. That meant I was on the right track: the issue was in Albino, not Jekyll. My next step was to figure out what Albino was doing internally to call pygmentize (the command line tool for Pygments). Albino spawns the pygmentize process on line 88 of /usr/lib/ruby/gems/1.9.1/gems/albino-1.3.3/lib/albino.rb. I inserted a puts command right before that line to see exactly what it was doing. The command it was calling internally looked like this:
pygmentize -l ruby -f html -O encoding=utf-8
To test it out, I ran the following:
$ echo 'puts "Hello World"' | pygmentize -l ruby -f html -O encoding=utf-8
*** Error while highlighting:
TypeError: Can't convert 'bytes' object to str implicitly
(file "/usr/lib/python3.2/codecs.py", line 355, in write)
It's one of those dreaded Python 3 bytes/str issues. I decided to try leaving out the encoding to see if I could easily bypass the issue:
$ echo 'puts "Hello World"' | pygmentize -l ruby -f html
<div class="highlight"><pre><span class="nb">puts</span> <span class="s2">"Hello World"</span>
</pre></div>
Looks like it worked! There might be some encoding issues later on, so I made a mental note to test it out after I was done. The next step was to prevent Albino from adding the -O encoding=utf-8 part to the command. On line 78 of the Albino file mentioned above (lib/albino.rb), the command line options for pygmentize are set:
@options = { :l => lexer, :f => format, :O => "encoding=#{encoding}" }
I just wanted to get Jekyll running, so I made a quick hack and removed the -O option:
@options = { :l => lexer, :f => format }
I went back to by Albino test program and verified that things worked:
$ ruby -e "require 'albino'; puts Albino.colorize('puts \'Hello World\'', :ruby)"
<div class="highlight"><pre><span class="nb">puts</span> <span class="s1">'Hello World'</span>
</pre>
</div>
Things were looking good! I went back to Jekyll and tried out a test page, and the highlighting seemed to work fine. One thing was left to check: did I screw anything up by removing the encoding from the command line call? I threw a couple non-ASCII characters in my code block as a test:
# coding: utf-8
# Calculate ∇·f(x,y,z), where f:ℝ³→ℝ³ is a vector field
def divergence(x, y, z, ε=1e-10)
f0 = yield(x,y,z)
δx = (yield(x+ε,y,z)[0] - f0[0]) / ε
δy = (yield(x,y+ε,z)[1] - f0[1]) / ε
δz = (yield(x,y,z+ε)[2] - f0[2]) / ε
δx + δy + δz
end
puts divergence(1,2,3) {|x,y,z| [-y,x*y,z]}
After rendering, it looked like it worked. My input text was in UTF-8, and I haven't tried anything else. There's a good chance it won't work if you use a different encoding.