Permalink
Browse files

TOC has leading empty list item

  • Loading branch information...
1 parent 4cf3608 commit 5b362fe6aeb4840789aaf6172e807319406cb201 @bdunagan bdunagan committed Oct 18, 2011
Showing with 11 additions and 0 deletions.
  1. +1 −0 lib/wikicloth/wiki_link_handler.rb
  2. +10 −0 test/wiki_cloth_test.rb
@@ -47,6 +47,7 @@ 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(sections).each do |section|
+ next if section.title.nil?
if section.depth > previous_depth
c = section.depth - previous_depth
c.times { ret += "<ul>" }
View
@@ -265,4 +265,14 @@ class WikiClothTest < ActiveSupport::TestCase
data = wiki.render
assert_equal data, "\n<p>A\n</p>\n<p><pre> B\n</pre>\n</p>"
end
+
+ test "empty item in toc" do
+ wiki = WikiCloth::WikiCloth.new({:data => "__TOC__\n=A="})
+ data = wiki.render
+ if RUBY_VERSION == "1.8.7"
+ assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div></li><li><a href=\"#A\">A</a></li></td></tr></table>\n<h1><span class=\"editsection\">&#91;<a href=\"?section=A\" title=\"Edit section: A\">edit</a>&#93;</span> <span class=\"mw-headline\" id=\"A\"><a name=\"A\">A</a></span></h1></p>"
+ else
+ assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div></li><li><a href=\"#A\">A</a></li></td></tr></table>\n<h1><span class=\"editsection\">&#91;<a href=\"?section=A\" title=\"Edit section: A\">edit</a>&#93;</span> <span id=\"A\" class=\"mw-headline\"><a name=\"A\">A</a></span></h1></p>"
+ end
+ end
end

0 comments on commit 5b362fe

Please sign in to comment.