aboutsummaryrefslogtreecommitdiff
path: root/plugins/include_code.rb
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/include_code.rb')
-rw-r--r--plugins/include_code.rb6
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)