diff options
Diffstat (limited to 'plugins/include_code.rb')
| -rw-r--r-- | plugins/include_code.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/plugins/include_code.rb b/plugins/include_code.rb index e064fe2c..70d5f138 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(/lang:\w+/i,'') + end if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i @title = $1 || nil @file = $3 @@ -52,12 +56,9 @@ module Jekyll Dir.chdir(code_path) do code = file.read - @filetype = file.extname.sub('.','') - @filetype = 'objc' if @filetype == 'm' - @filetype = 'perl' if @filetype == 'pl' - @filetype = 'yaml' if @filetype == 'yml' + @filetype = file.extname.sub('.','') if @filetype.nil? title = @title ? "#{@title} (#{file.basename})" : file.basename - url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}" + url = "/#{code_dir}/#{@file}" source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n" source += " #{highlight(code, @filetype)}</figure></div>" end |
