Context is not used within any of the renders so no need to pass it
This commit is contained in:
parent
d6bd735aff
commit
446ca8f73d
|
@ -35,16 +35,18 @@ eos
|
||||||
|
|
||||||
output = case context.registers[:site].highlighter
|
output = case context.registers[:site].highlighter
|
||||||
when 'pygments'
|
when 'pygments'
|
||||||
render_pygments(context, code)
|
render_pygments(code)
|
||||||
when 'rouge'
|
when 'rouge'
|
||||||
render_rouge(context, code)
|
render_rouge(code)
|
||||||
else
|
else
|
||||||
render_codehighlighter(context, code)
|
render_codehighlighter(code)
|
||||||
end.strip
|
|
||||||
prefix + add_code_tag(output) + suffix
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_pygments(context, code)
|
rendered_output = add_code_tag(output)
|
||||||
|
prefix + rendered_output + suffix
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_pygments(code)
|
||||||
require 'pygments'
|
require 'pygments'
|
||||||
@options[:encoding] = 'utf-8'
|
@options[:encoding] = 'utf-8'
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ eos
|
||||||
highlighted_code
|
highlighted_code
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_rouge(context, code)
|
def render_rouge(code)
|
||||||
require 'rouge'
|
require 'rouge'
|
||||||
formatter = Rouge::Formatters::HTML.new(line_numbers: @options[:linenos], wrap: false)
|
formatter = Rouge::Formatters::HTML.new(line_numbers: @options[:linenos], wrap: false)
|
||||||
lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
|
lexer = Rouge::Lexer.find_fancy(@lang, code) || Rouge::Lexers::PlainText
|
||||||
|
@ -72,7 +74,7 @@ eos
|
||||||
"<div class=\"highlight\"><pre>#{code}</pre></div>"
|
"<div class=\"highlight\"><pre>#{code}</pre></div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_codehighlighter(context, code)
|
def render_codehighlighter(code)
|
||||||
"<div class=\"highlight\"><pre>#{h(code).strip}</pre></div>"
|
"<div class=\"highlight\"><pre>#{h(code).strip}</pre></div>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue