mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2025-02-28 16:31:44 -05:00
Merge branch 'site' of github.com:imathis/octopress into site
This commit is contained in:
commit
2e4f95212a
@ -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
|
||||
@ -77,9 +82,6 @@ module Jekyll
|
||||
source += @caption if @caption
|
||||
source = context['pygments_prefix'] + source if context['pygments_prefix']
|
||||
if @filetype
|
||||
@filetype = 'objc' if @filetype == 'm'
|
||||
@filetype = 'perl' if @filetype == 'pl'
|
||||
@filetype = 'yaml' if @filetype == 'yml'
|
||||
source += " #{highlight(code, @filetype)}</figure></div>"
|
||||
else
|
||||
source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'<'))}</figure></div>"
|
||||
|
@ -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,10 +56,7 @@ 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}"
|
||||
source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n"
|
||||
|
@ -7,6 +7,10 @@ FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
|
||||
|
||||
module HighlightCode
|
||||
def highlight(str, lang)
|
||||
lang = 'ruby' if lang == 'ru'
|
||||
lang = 'objc' if lang == 'm'
|
||||
lang = 'perl' if lang == 'pl'
|
||||
lang = 'yaml' if lang == 'yml'
|
||||
str = pygments(str, lang).match(/<pre>(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs <div class="highlight">
|
||||
tableize_code(str, lang)
|
||||
end
|
||||
|
@ -27,3 +27,7 @@ fi
|
||||
done
|
||||
unset i
|
||||
{% endcodeblock %}
|
||||
|
||||
{% codeblock config.ru %}
|
||||
Bunch of ruby code
|
||||
{% endcodeblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user