mirror of
https://github.com/WatchOutNewsAgency/wona.github.com.git
synced 2026-01-01 01:16:26 +00:00
added support for pygments.rb removing dependency on pygments, added support for caching highlighted code from pygments.rb and added default line numbering. Javascript auto line numbering now only occurs for embedded gists
This commit is contained in:
@ -20,11 +20,13 @@
|
||||
# will output a figcaption with the title: Example 2 (test.js)
|
||||
#
|
||||
|
||||
require './plugins/pygments_code'
|
||||
require 'pathname'
|
||||
|
||||
module Jekyll
|
||||
|
||||
class IncludeCodeTag < Liquid::Tag
|
||||
include HighlightCode
|
||||
def initialize(tag_name, markup, tokens)
|
||||
@title = nil
|
||||
@file = nil
|
||||
@ -50,13 +52,13 @@ module Jekyll
|
||||
|
||||
Dir.chdir(code_path) do
|
||||
code = file.read
|
||||
@filetype = file.extname
|
||||
@filetype = file.extname.sub('.','')
|
||||
@filetype = 'objc' if @filetype == 'm'
|
||||
@filetype = 'perl' if @filetype == 'pl'
|
||||
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"
|
||||
source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}</figure></div>"
|
||||
source += " #{highlight(code, @filetype)}</figure></div>"
|
||||
partial = Liquid::Template.parse(source)
|
||||
context.stack do
|
||||
partial.render(context)
|
||||
|
||||
Reference in New Issue
Block a user