RailsCasts Pro episodes are now free!

Learn more or hide this

Elliot's Profile

GitHub User: venturemedias

Comments by Elliot

Avatar

To do this with heroku, change syntax_highlighter to the following:

ruby
  def syntax_highlighter(html)
    doc = Nokogiri::HTML(html)
    doc.search("//pre[@lang]").each do |pre|
      lang = pre[:lang]
      code = pre.text.rstrip
      request = Net::HTTP.post_form(URI.parse('http://pygments.appspot.com/'), {'lang'=>lang, 'code'=>code})
      pre.replace request.body
    end
    doc.to_s
  end