Liquid::Block
The regular expression syntax checker. Start with the language specifier. Follow that by zero or more space separated options that take one of two forms:
name
name=value
# File lib/jekyll/tags/highlight.rb, line 14 def initialize(tag_name, markup, tokens) super if markup.strip =~ SYNTAX @lang = $1 @options = {} if defined?($2) && $2 != '' $2.split.each do |opt| key, value = opt.split('=') if value.nil? if key == 'linenos' value = 'inline' else value = true end end @options[key] = value end end else raise SyntaxError.new Syntax Error in tag 'highlight' while parsing the following markup: #{markup}Valid syntax: highlight <lang> [linenos] end end
# File lib/jekyll/tags/highlight.rb, line 43 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 66 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 51 def render_pygments(context, code) require 'pygments' @options[:encoding] = 'utf-8' output = add_code_tags( Pygments.highlight(code, :lexer => @lang, :options => @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.