diff options
author | Brandon Mathis <brandon@imathis.com> | 2011-08-20 20:24:51 -0400 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2011-08-20 20:25:07 -0400 |
commit | 83d87f98cc22dd00bc1ececcb3022ae9ccb964cb (patch) | |
tree | cd2f08179c241825ab9d6c0349a9c5df5a774776 /plugins/include_code.rb | |
parent | 67211edd97beb77ea6d2be259d6ed9a07bdd9c9e (diff) | |
download | my_new_personal_website-83d87f98cc22dd00bc1ececcb3022ae9ccb964cb.tar.xz my_new_personal_website-83d87f98cc22dd00bc1ececcb3022ae9ccb964cb.zip |
added option to force syntax highlighting language, example: {% include_code file lang:ruby %}. Fixes #108
Diffstat (limited to '')
-rw-r--r-- | plugins/include_code.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/include_code.rb b/plugins/include_code.rb index d910c3e6..046f6245 100644 --- a/plugins/include_code.rb +++ b/plugins/include_code.rb @@ -30,6 +30,10 @@ module Jekyll def initialize(tag_name, markup, tokens) @title = nil @file = nil + if markup.strip =~ /\s+lang:(\w+)/i + @filetype = $1 + markup = markup.strip.sub(/\s+lang:\w+\s*/i,'') + end if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i @title = $1 || nil @file = $3 @@ -52,7 +56,7 @@ module Jekyll Dir.chdir(code_path) do code = file.read - @filetype = file.extname.sub('.','') + @filetype = file.extname.sub('.','') if @filetype.nil? 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" |