Merge pull request #1048 from mojombo/fix-toc-rdiscount
Check to make sure there is a toc_token before trying to use it.
This commit is contained in:
commit
541dbf1a04
|
@ -15,11 +15,20 @@ module Jekyll
|
||||||
def convert(content)
|
def convert(content)
|
||||||
rd = RDiscount.new(content, *@rdiscount_extensions)
|
rd = RDiscount.new(content, *@rdiscount_extensions)
|
||||||
html = rd.to_html
|
html = rd.to_html
|
||||||
if rd.generate_toc and html.include?(@config['rdiscount']['toc_token'])
|
if @config['rdiscount']['toc_token']
|
||||||
html.gsub!(@config['rdiscount']['toc_token'], rd.toc_content.force_encoding('utf-8'))
|
html = replace_generated_toc(rd, html, @config['rdiscount']['toc_token'])
|
||||||
end
|
end
|
||||||
html
|
html
|
||||||
end
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue