... | ... |
@@ -53,7 +53,12 @@ module Jekyll |
53 | 53 |
def initialize(tag_name, markup, tokens) |
54 | 54 |
@title = nil |
55 | 55 |
@caption = nil |
56 |
+ @filetype = nil |
|
56 | 57 |
@highlight = true |
58 |
+ if markup =~ /\s+lang:(\w+)/i |
|
59 |
+ @filetype = $1 |
|
60 |
+ markup = markup.sub(/\s+lang:\w+\s*/i,'') |
|
61 |
+ end |
|
57 | 62 |
if markup =~ CaptionUrlTitle |
58 | 63 |
@file = $1 |
59 | 64 |
@caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>" |
... | ... |
@@ -64,7 +69,7 @@ module Jekyll |
64 | 64 |
@file = $1 |
65 | 65 |
@caption = "<figcaption><span>#{$1}</span></figcaption>\n" |
66 | 66 |
end |
67 |
- if @file =~ /\S[\S\s]*\w+\.(\w+)/ |
|
67 |
+ if @file =~ /\S[\S\s]*\w+\.(\w+)/ && @filetype.nil? |
|
68 | 68 |
@filetype = $1 |
69 | 69 |
end |
70 | 70 |
super |
... | ... |
@@ -30,6 +30,10 @@ module Jekyll |
30 | 30 |
def initialize(tag_name, markup, tokens) |
31 | 31 |
@title = nil |
32 | 32 |
@file = nil |
33 |
+ if markup.strip =~ /\s+lang:(\w+)/i |
|
34 |
+ @filetype = $1 |
|
35 |
+ markup = markup.strip.sub(/\s+lang:\w+\s*/i,'') |
|
36 |
+ end |
|
33 | 37 |
if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i |
34 | 38 |
@title = $1 || nil |
35 | 39 |
@file = $3 |
... | ... |
@@ -52,7 +56,7 @@ module Jekyll |
52 | 52 |
|
53 | 53 |
Dir.chdir(code_path) do |
54 | 54 |
code = file.read |
55 |
- @filetype = file.extname.sub('.','') |
|
55 |
+ @filetype = file.extname.sub('.','') if @filetype.nil? |
|
56 | 56 |
title = @title ? "#{@title} (#{file.basename})" : file.basename |
57 | 57 |
url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}" |
58 | 58 |
source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n" |