Skip to content

Commit

Permalink
rendering TOC errors on undefined 'sections'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunagan committed Oct 18, 2011
1 parent 3027538 commit 86cfda9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/wikicloth/wiki_link_handler.rb
Expand Up @@ -46,7 +46,7 @@ def section_list(root=nil)
def toc(sections)
ret = "<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div>"
previous_depth = 1
section_list.each do |section|
section_list(sections).each do |section|
if section.depth > previous_depth
c = section.depth - previous_depth
c.times { ret += "<ul>" }
Expand Down
6 changes: 6 additions & 0 deletions test/wiki_cloth_test.rb
Expand Up @@ -241,4 +241,10 @@ class WikiClothTest < ActiveSupport::TestCase
assert_equal data, "\n<p><h1><span id=\"Hallo\" class=\"mw-headline\"><a name=\"Hallo\">Hallo</a></span></h1></p>"
end
end

test "render toc" do
wiki = WikiCloth::WikiCloth.new({:data => "=A=\n=B=\n=C=\n=D="})
data = wiki.render
assert data =~ /A/
end
end

0 comments on commit 86cfda9

Please sign in to comment.