Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/site/_plugins/pygments_cache.rb

Issue 10700168: massive CL is massive (Closed) Base URL: https://code.google.com/p/dartlang-site/@master
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/site/_plugins/asset_bundler.rb ('k') | src/site/_plugins/sitemap_generator.rb » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 require 'fileutils'
2 require 'digest/md5'
3
4 PYGMENTS_CACHE_DIR = File.expand_path('../../_cache', __FILE__)
5 FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
6
7 Jekyll::HighlightBlock.class_eval do
8 def render_pygments(context, code)
9 if defined?(PYGMENTS_CACHE_DIR)
10 path = File.join(PYGMENTS_CACHE_DIR, "#{@lang}-#{Digest::MD5.hexdigest(cod e)}.html")
11 if File.exist?(path)
12 highlighted_code = File.read(path)
13 else
14 highlighted_code = Albino.new(code, @lang).to_s(@options)
15 File.open(path, 'w') {|f| f.print(highlighted_code) }
16 end
17 else
18 highlighted_code = Albino.new(code, @lang).to_s(@options)
19 end
20 output = add_code_tags(highlighted_code, @lang)
21 output = context["pygments_prefix"] + output if context["pygments_prefix"]
22 output = output + context["pygments_suffix"] if context["pygments_suffix"]
23 output
24 end
25
26 end
OLDNEW
« no previous file with comments | « src/site/_plugins/asset_bundler.rb ('k') | src/site/_plugins/sitemap_generator.rb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698