Liquid::Block
We need a language, but the linenos argument is optional.
# File lib/jekyll/tags/highlight.rb, line 9 def initialize(tag_name, markup, tokens) super if markup =~ SYNTAX @lang = $1 if defined? $2 tmp_options = {} $2.split.each do |opt| key, value = opt.split('=') if value.nil? if key == 'linenos' value = 'inline' else value = true end end tmp_options[key] = value end tmp_options = tmp_options.to_a.collect { |opt| opt.join('=') } # additional options to pass to Albino @options = { 'O' => tmp_options.join(',') } else @options = {} end else raise SyntaxError.new("Syntax Error in 'highlight' - Valid syntax: highlight <lang> [linenos]") end end
# File lib/jekyll/tags/highlight.rb, line 37 def render(context) if context.registers[:site].pygments render_pygments(context, super) else render_codehighlighter(context, super) end end
# File lib/jekyll/tags/highlight.rb, line 52 def render_codehighlighter(context, code) #The div is required because RDiscount blows ass <div> <pre><code class='#{@lang}'>#{h(code).strip}</code></pre></div> end
# File lib/jekyll/tags/highlight.rb, line 45 def render_pygments(context, code) output = add_code_tags(Albino.new(code, @lang).to_s(@options), @lang) output = context["pygments_prefix"] + output if context["pygments_prefix"] output = output + context["pygments_suffix"] if context["pygments_suffix"] output end
Generated with the Darkfish Rdoc Generator 2.