Skip to content

Instantly share code, notes, and snippets.

@vadv
Last active October 8, 2015 15:08
Show Gist options
  • Save vadv/3349275 to your computer and use it in GitHub Desktop.
Save vadv/3349275 to your computer and use it in GitHub Desktop.
@@ -1,7 +1,9 @@
-require 'pygments'
+require 'net/http'
+require 'uri'
require 'fileutils'
require 'digest/md5'
+PYGMENTIZE_URL = URI.parse('http://pygmentize.herokuapp.com/')
PYGMENTS_CACHE_DIR = File.expand_path('../../.pygments-cache', __FILE__)
FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
@@ -21,11 +23,11 @@ module HighlightCode
if File.exist?(path)
highlighted_code = File.read(path)
else
- highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'ut
+ highlighted_code = Net::HTTP.post_form(PYGMENTIZE_URL, {'lang'=>lang, 'code'=>code}).body
File.open(path, 'w') {|f| f.print(highlighted_code) }
end
else
- highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-
+ highlighted_code = Net::HTTP.post_form(PYGMENTIZE_URL, {'lang'=>lang, 'code'=>code}).body
end
highlighted_code
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment