Merge pull request #616 from hokaccha/fix_pygments_opt

fixed pygments linenos options for pygments.rb
This commit is contained in:
Parker Moore 2013-01-12 00:11:18 -08:00
commit a05b9159d9
2 changed files with 6 additions and 11 deletions

View File

@ -15,8 +15,8 @@ module Jekyll
super super
if markup.strip =~ SYNTAX if markup.strip =~ SYNTAX
@lang = $1 @lang = $1
@options = {}
if defined?($2) && $2 != '' if defined?($2) && $2 != ''
tmp_options = {}
$2.split.each do |opt| $2.split.each do |opt|
key, value = opt.split('=') key, value = opt.split('=')
if value.nil? if value.nil?
@ -26,13 +26,8 @@ module Jekyll
value = true value = true
end end
end end
tmp_options[key] = value @options[key] = value
end end
tmp_options = tmp_options.to_a.sort.collect { |opt| opt.join('=') }
# additional options to pass to Albino
@options = { 'O' => tmp_options.join(',') }
else
@options = {}
end end
else else
raise SyntaxError.new("Syntax Error in 'highlight' - Valid syntax: highlight <lang> [linenos]") raise SyntaxError.new("Syntax Error in 'highlight' - Valid syntax: highlight <lang> [linenos]")

View File

@ -58,16 +58,16 @@ CONTENT
assert_equal({}, tag.instance_variable_get(:@options)) assert_equal({}, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"])
assert_equal({'O' => "linenos=inline"}, tag.instance_variable_get(:@options)) assert_equal({ 'linenos' => 'inline' }, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"])
assert_equal({'O' => "linenos=table"}, tag.instance_variable_get(:@options)) assert_equal({ 'linenos' => 'table' }, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"])
assert_equal({'O' => "linenos=table,nowrap=true"}, tag.instance_variable_get(:@options)) assert_equal({ 'linenos' => 'table', 'nowrap' => true }, tag.instance_variable_get(:@options))
tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"]) tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"])
assert_equal({'O' => "cssclass=hl,linenos=table"}, tag.instance_variable_get(:@options)) assert_equal({ 'cssclass' => 'hl', 'linenos' => 'table' }, tag.instance_variable_get(:@options))
end end
end end