diff --git a/lib/jekyll/converters/markdown/kramdown_parser.rb b/lib/jekyll/converters/markdown/kramdown_parser.rb index be9e80b4..caeb5b65 100644 --- a/lib/jekyll/converters/markdown/kramdown_parser.rb +++ b/lib/jekyll/converters/markdown/kramdown_parser.rb @@ -16,7 +16,7 @@ module Jekyll if @config['kramdown']['use_coderay'] %w[wrap line_numbers line_numbers_start tab_width bold_every css default_lang].each do |opt| key = "coderay_#{opt}" - @config['kramdown'][key.to_sym] = @config['kramdown']['coderay'][key] unless @config['kramdown'].has_key?(key) + @config['kramdown'][key] = @config['kramdown']['coderay'][key] unless @config['kramdown'].has_key?(key) end end diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index eed8b97f..1d4c09ff 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -12,24 +12,51 @@ class TestKramdown < Test::Unit::TestCase 'footnote_nr' => 1, 'entity_output' => 'as_char', 'toc_levels' => '1..6', - 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo' + 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo', + + 'use_coderay' => true, + 'coderay_bold_every'=> 12, + 'coderay' => { + 'coderay_css' => :style, + 'coderay_bold_every' => 8 + } } } + @config = Jekyll.configuration(@config) + @markdown = Converters::Markdown.new(@config) end # http://kramdown.rubyforge.org/converter/html.html#options should "pass kramdown options" do - markdown = Converters::Markdown.new(@config) - assert_equal "

Some Header

", markdown.convert('# Some Header #').strip + assert_equal "

Some Header

", @markdown.convert('# Some Header #').strip end should "convert quotes to smart quotes" do - markdown = Converters::Markdown.new(@config) - assert_match /

(“|“)Pit(’|’)hy(”|”)<\/p>/, markdown.convert(%{"Pit'hy"}).strip + assert_match /

(“|“)Pit(’|’)hy(”|”)<\/p>/, @markdown.convert(%{"Pit'hy"}).strip override = { 'kramdown' => { 'smart_quotes' => 'lsaquo,rsaquo,laquo,raquo' } } markdown = Converters::Markdown.new(@config.deep_merge(override)) assert_match /

(«|«)Pit(›|›)hy(»|»)<\/p>/, markdown.convert(%{"Pit'hy"}).strip end + + context "moving up nested coderay options" do + setup do + @markdown.convert('some markup') + @converter_config = @markdown.instance_variable_get(:@config)['kramdown'] + end + + should "work correctly" do + assert_equal :style, @converter_config['coderay_css'] + end + + should "also work for defaults" do + default = Jekyll::Configuration::DEFAULTS['kramdown']['coderay']['coderay_tab_width'] + assert_equal default, @converter_config['coderay_tab_width'] + end + + should "not overwrite" do + assert_equal 12, @converter_config['coderay_bold_every'] + end + end end end