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/code_block.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 'plugins/code_block.rb')
-rw-r--r-- | plugins/code_block.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/plugins/code_block.rb b/plugins/code_block.rb index d82893ea..4d7ca6bb 100644 --- a/plugins/code_block.rb +++ b/plugins/code_block.rb @@ -53,7 +53,12 @@ module Jekyll def initialize(tag_name, markup, tokens) @title = nil @caption = nil + @filetype = nil @highlight = true + if markup =~ /\s+lang:(\w+)/i + @filetype = $1 + markup = markup.sub(/\s+lang:\w+\s*/i,'') + end if markup =~ CaptionUrlTitle @file = $1 @caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>" @@ -64,7 +69,7 @@ module Jekyll @file = $1 @caption = "<figcaption><span>#{$1}</span></figcaption>\n" end - if @file =~ /\S[\S\s]*\w+\.(\w+)/ + if @file =~ /\S[\S\s]*\w+\.(\w+)/ && @filetype.nil? @filetype = $1 end super |