Skip to content

Commit

Permalink
Merge pull request #1048 from mojombo/fix-toc-rdiscount
Browse files Browse the repository at this point in the history
Check to make sure there is a toc_token before trying to use it.
  • Loading branch information
parkr committed May 7, 2013
2 parents 81fea5a + 1d2f172 commit 541dbf1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/jekyll/converters/markdown/rdiscount_parser.rb
Expand Up @@ -15,11 +15,20 @@ def initialize(config)
def convert(content)
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.force_encoding('utf-8'))
if @config['rdiscount']['toc_token']
html = replace_generated_toc(rd, html, @config['rdiscount']['toc_token'])
end
html
end

private
def replace_generated_toc(rd, html, toc_token)
if rd.generate_toc && html.include?(toc_token)
html.gsub(toc_token, rd.toc_content.force_encoding('utf-8'))
else
html
end
end
end
end
end
Expand Down

0 comments on commit 541dbf1

Please sign in to comment.