diff --git a/History.txt b/History.txt index 9f6307a0..3fbe4da1 100644 --- a/History.txt +++ b/History.txt @@ -5,6 +5,7 @@ * Allow setting of RedCloth options (#284) * Add post_url Liquid tag for internal post linking (#369) * Allow multiple plugin dirs to be specified (#438) + * Inline TOC token support for RDiscount (#333) * Bug Fixes * Allow some special characters in highlight names * URL escape category names in URL generation (#360) diff --git a/lib/jekyll/converters/markdown.rb b/lib/jekyll/converters/markdown.rb index 32820ef4..cb94c8d0 100644 --- a/lib/jekyll/converters/markdown.rb +++ b/lib/jekyll/converters/markdown.rb @@ -119,8 +119,8 @@ module Jekyll when 'rdiscount' rd = RDiscount.new(content, *@rdiscount_extensions) html = rd.to_html - if rd.generate_toc and html.include? @config['rdiscount']['toc_token'] - html.gsub! @config['rdiscount']['toc_token'], rd.toc_content + if rd.generate_toc and html.include?(@config['rdiscount']['toc_token']) + html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content) end html when 'maruku' diff --git a/test/test_rdiscount.rb b/test/test_rdiscount.rb index 2669b446..01f18eb3 100644 --- a/test/test_rdiscount.rb +++ b/test/test_rdiscount.rb @@ -5,8 +5,8 @@ class TestRdiscount < Test::Unit::TestCase context "rdiscount" do setup do config = { - 'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' }, - 'markdown' => 'rdiscount' + 'markdown' => 'rdiscount', + 'rdiscount' => { 'extensions' => ['smart', 'generate_toc'], 'toc_token' => '{:toc}' } } @markdown = MarkdownConverter.new config end