From 7b81aab5ac225fb12a100d9eb463340f322704fd Mon Sep 17 00:00:00 2001 From: Brandon Mathis Date: Tue, 26 Jul 2011 23:36:42 -0400 Subject: 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 --- plugins/include_code.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'plugins/include_code.rb') 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 = "
#{title} download
\n" - source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}
" + source += " #{highlight(code, @filetype)}" partial = Liquid::Template.parse(source) context.stack do partial.render(context) -- cgit v1.2.1