Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TOC should be declared as list

  • Loading branch information...
commit 6f80270c9298d5a01f7f767b88ee2753a07b7897 1 parent ee6f9ca
@bdunagan bdunagan authored
Showing with 14 additions and 4 deletions.
  1. +2 −2 lib/wikicloth/wiki_link_handler.rb
  2. +12 −2 test/wiki_cloth_test.rb
View
4 lib/wikicloth/wiki_link_handler.rb
@@ -44,7 +44,7 @@ def section_list(root=nil)
end
def toc(sections)
- ret = "<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div>"
+ ret = "<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul>"
previous_depth = 1
section_list(sections).each do |section|
next if section.title.nil?
@@ -64,7 +64,7 @@ def toc(sections)
end
ret += "</li>"
(previous_depth-1).times { ret += "</ul>" }
- "#{ret}</td></tr></table>"
+ "#{ret}</ul></td></tr></table>"
end
def external_links
View
14 test/wiki_cloth_test.rb
@@ -270,9 +270,9 @@ class WikiClothTest < ActiveSupport::TestCase
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>"
+ assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a></li></ul></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>"
+ assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a></li></ul></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
@@ -281,4 +281,14 @@ class WikiClothTest < ActiveSupport::TestCase
data = wiki.render
assert_equal data, "\n\n<p><pre> A\n</pre>\n</p>"
end
+
+ test "toc declared as list" do
+ wiki = WikiCloth::WikiCloth.new({:data => "__TOC__\n=A=\n==B==\n===C==="})
+ 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><ul></li><li><a href=\"#A\">A</a><ul><li><a href=\"#B\">B</a><ul><li><a href=\"#C\">C</a></li></ul></ul></ul></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>\n<h2><span class=\"editsection\">&#91;<a href=\"?section=B\" title=\"Edit section: B\">edit</a>&#93;</span> <span class=\"mw-headline\" id=\"B\"><a name=\"B\">B</a></span></h2>\n<h3><span class=\"editsection\">&#91;<a href=\"?section=C\" title=\"Edit section: C\">edit</a>&#93;</span> <span class=\"mw-headline\" id=\"C\"><a name=\"C\">C</a></span></h3></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><ul></li><li><a href=\"#A\">A</a><ul><li><a href=\"#B\">B</a><ul><li><a href=\"#C\">C</a></li></ul></ul></ul></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>\n<h2><span class=\"editsection\">&#91;<a href=\"?section=B\" title=\"Edit section: B\">edit</a>&#93;</span> <span id=\"B\" class=\"mw-headline\"><a name=\"B\">B</a></span></h2>\n<h3><span class=\"editsection\">&#91;<a href=\"?section=C\" title=\"Edit section: C\">edit</a>&#93;</span> <span id=\"C\" class=\"mw-headline\"><a name=\"C\">C</a></span></h3></p>"
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.