From 29d0841e9798e4ce79f05512d577211cf8a38560 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Thu, 12 Sep 2013 22:36:42 +0200 Subject: [PATCH 1/3] #to_sym is called by #symbolize_keys --- lib/jekyll/converters/markdown/kramdown_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 76d56c2352d4923094f7c7c55f7229608214a9b4 Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Thu, 12 Sep 2013 22:23:58 +0200 Subject: [PATCH 2/3] shorten test code by moving converter instantiation to #setup --- test/test_kramdown.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index eed8b97f..a442573d 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -15,17 +15,16 @@ class TestKramdown < Test::Unit::TestCase 'smart_quotes' => 'lsquo,rsquo,ldquo,rdquo' } } + @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)) From ed58ba15082333fe9f0f287288ce33a62202232e Mon Sep 17 00:00:00 2001 From: "maul.esel" Date: Thu, 12 Sep 2013 22:34:05 +0200 Subject: [PATCH 3/3] add tests for moving of coderay settings for kramdown --- test/test_kramdown.rb | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/test_kramdown.rb b/test/test_kramdown.rb index a442573d..1d4c09ff 100644 --- a/test/test_kramdown.rb +++ b/test/test_kramdown.rb @@ -12,9 +12,17 @@ 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 @@ -30,5 +38,25 @@ class TestKramdown < Test::Unit::TestCase 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