mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-24 08:28:50 -05:00
added option to force syntax highlighting language, example: {% include_code file lang:ruby %}. Fixes #108
This commit is contained in:
parent
67211edd97
commit
83d87f98cc
@ -53,7 +53,12 @@ module Jekyll
|
|||||||
def initialize(tag_name, markup, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
@title = nil
|
@title = nil
|
||||||
@caption = nil
|
@caption = nil
|
||||||
|
@filetype = nil
|
||||||
@highlight = true
|
@highlight = true
|
||||||
|
if markup =~ /\s+lang:(\w+)/i
|
||||||
|
@filetype = $1
|
||||||
|
markup = markup.sub(/\s+lang:\w+\s*/i,'')
|
||||||
|
end
|
||||||
if markup =~ CaptionUrlTitle
|
if markup =~ CaptionUrlTitle
|
||||||
@file = $1
|
@file = $1
|
||||||
@caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>"
|
@caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>"
|
||||||
@ -64,7 +69,7 @@ module Jekyll
|
|||||||
@file = $1
|
@file = $1
|
||||||
@caption = "<figcaption><span>#{$1}</span></figcaption>\n"
|
@caption = "<figcaption><span>#{$1}</span></figcaption>\n"
|
||||||
end
|
end
|
||||||
if @file =~ /\S[\S\s]*\w+\.(\w+)/
|
if @file =~ /\S[\S\s]*\w+\.(\w+)/ && @filetype.nil?
|
||||||
@filetype = $1
|
@filetype = $1
|
||||||
end
|
end
|
||||||
super
|
super
|
||||||
|
@ -30,6 +30,10 @@ module Jekyll
|
|||||||
def initialize(tag_name, markup, tokens)
|
def initialize(tag_name, markup, tokens)
|
||||||
@title = nil
|
@title = nil
|
||||||
@file = 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
|
if markup.strip =~ /(.*)?(\s+|^)(\/*\S+)/i
|
||||||
@title = $1 || nil
|
@title = $1 || nil
|
||||||
@file = $3
|
@file = $3
|
||||||
@ -52,7 +56,7 @@ module Jekyll
|
|||||||
|
|
||||||
Dir.chdir(code_path) do
|
Dir.chdir(code_path) do
|
||||||
code = file.read
|
code = file.read
|
||||||
@filetype = file.extname.sub('.','')
|
@filetype = file.extname.sub('.','') if @filetype.nil?
|
||||||
title = @title ? "#{@title} (#{file.basename})" : file.basename
|
title = @title ? "#{@title} (#{file.basename})" : file.basename
|
||||||
url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
|
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 = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user