diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-07-26 23:36:42 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-07-26 23:36:42 -0400 |
commit | 7b81aab5ac225fb12a100d9eb463340f322704fd (patch) | |
tree | f46adc303a4f5b4510d8880c8d5820173c931414 /plugins/include_code.rb | |
parent | 727a1492278c5e22aa68019f14d4e60319476f74 (diff) | |
download | my_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/include_code.rb')
-rw-r--r-- | plugins/include_code.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/include_code.rb b/plugins/include_code.rb index b0258a4c..93db78a3 100644 --- a/plugins/include_code.rb +++ b/plugins/include_code.rb @@ -20,11 +20,13 @@ # will output a figcaption with the title: Example 2 (test.js) # +require './plugins/pygments_code' require 'pathname' module Jekyll class IncludeCodeTag < Liquid::Tag + include HighlightCode def initialize(tag_name, markup, tokens) @title = nil @file = nil @@ -50,13 +52,13 @@ module Jekyll Dir.chdir(code_path) do code = file.read - @filetype = file.extname + @filetype = file.extname.sub('.','') @filetype = 'objc' if @filetype == 'm' @filetype = 'perl' if @filetype == 'pl' title = @title ? "#{@title} (#{file.basename})" : file.basename url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}" source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n" - source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}</figure></div>" + source += " #{highlight(code, @filetype)}</figure></div>" partial = Liquid::Template.parse(source) context.stack do partial.render(context) |