I’m running a Octopress blog which is based on Jekyll. Now I wanted to add some Javascript which I like to write in CoffeeScript.
I followed this Gist to create a simple converter that compiles CoffeeScript to Javascript:
module Jekyll
require 'coffee-script'
class CoffeeScriptConverter < Converter
safe true
priority :low
def matches(ext)
ext =~ /coffee/i
end
def output_ext(ext)
'.js'
end
def convert(content)
begin
CoffeeScript.compile content
rescue StandardError => e
puts "CoffeeScript error: #{e.message}"
end
end
end
end
The problem is that the generated Javascript file has all quotes escaped (single quotes by ‘ and double quotes by “)
When I output the generated Javascript code in the convert method, it looks fine (quotes are not escaped).
I googled a lot but nobody seems to have this problem.
What could be the issue here?
Turns out Octopress runs the content through RubyPants by default (see
plugins/octopress_filters.rb). Disabling RubyPants did the trick!