aboutsummaryrefslogtreecommitdiff
path: root/plugins/pygments_cache_patch.rb
diff options
context:
space:
mode:
authorBrandon Mathis <brandon@imathis.com>2011-07-26 23:36:42 -0400
committerBrandon Mathis <brandon@imathis.com>2011-07-26 23:36:42 -0400
commit7b81aab5ac225fb12a100d9eb463340f322704fd (patch)
treef46adc303a4f5b4510d8880c8d5820173c931414 /plugins/pygments_cache_patch.rb
parent727a1492278c5e22aa68019f14d4e60319476f74 (diff)
downloadmy_new_personal_website-7b81aab5ac225fb12a100d9eb463340f322704fd.tar.xz
my_new_personal_website-7b81aab5ac225fb12a100d9eb463340f322704fd.zip
added support for pygments.rb removing dependency on pygments, added support for caching highlighted code from pygments.rb and added default line numbering. Javascript auto line numbering now only occurs for embedded gists
Diffstat (limited to 'plugins/pygments_cache_patch.rb')
-rw-r--r--plugins/pygments_cache_patch.rb30
1 files changed, 0 insertions, 30 deletions
diff --git a/plugins/pygments_cache_patch.rb b/plugins/pygments_cache_patch.rb
deleted file mode 100644
index 09c09840..00000000
--- a/plugins/pygments_cache_patch.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Author: Raimonds Simanovskis, http://blog.rayapps.com/
-# Source URL: https://github.com/rsim/blog.rayapps.com/blob/master/_plugins/pygments_cache_patch.rb
-#
-
-require 'fileutils'
-require 'digest/md5'
-
-PYGMENTS_CACHE_DIR = File.expand_path('../../_code_cache', __FILE__)
-FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
-
-Jekyll::HighlightBlock.class_eval do
- def render_pygments(context, code)
- if defined?(PYGMENTS_CACHE_DIR)
- path = File.join(PYGMENTS_CACHE_DIR, "#{@lang}-#{Digest::MD5.hexdigest(code)}.html")
- if File.exist?(path)
- highlighted_code = File.read(path)
- else
- highlighted_code = Albino.new(code, @lang).to_s(@options)
- File.open(path, 'w') {|f| f.print(highlighted_code) }
- end
- else
- highlighted_code = Albino.new(code, @lang).to_s(@options)
- end
- output = add_code_tags(highlighted_code, @lang)
- output = context["pygments_prefix"] + output if context["pygments_prefix"]
- output = output + context["pygments_suffix"] if context["pygments_suffix"]
- output
- end
-end