Merge pull request #55 from Artiavis/fixing-generate-toc-true

Add regression for the old style of using {:toc true}
This commit is contained in:
Carmen La 2015-11-09 21:35:55 -05:00
commit 2eb469ee3f
2 changed files with 17 additions and 2 deletions

View file

@ -99,6 +99,7 @@
contents, while :ul will result in an unordered list. The default is an
ordered list."
[^String html & {:keys [list-type] :or {list-type :ol}}]
(let [list-type (if (true? list-type) :ol list-type)]
(-> html
(.getBytes "UTF-8")
(java.io.ByteArrayInputStream.)
@ -107,4 +108,4 @@
(get-headings)
(build-toc-tree)
(build-toc list-type)
(hiccup/html)))
(hiccup/html))))

View file

@ -93,3 +93,17 @@
"but outer headers cannot be less indented "
"than the original header."]))
))
(deftest test-generate-toc
(let [htmlString "<div><h2><a name=\"test\"></a>Test</h2></div>"]
(is (= "<ol class=\"content\"><li><a href=\"#test\">Test</a></li></ol>"
(generate-toc htmlString)))
(is (= "<ol class=\"content\"><li><a href=\"#test\">Test</a></li></ol>"
(generate-toc htmlString :list-type true)))
(is (= "<ol class=\"content\"><li><a href=\"#test\">Test</a></li></ol>"
(generate-toc htmlString :list-type :ol)))
(is (= "<ul class=\"content\"><li><a href=\"#test\">Test</a></li></ul>"
(generate-toc htmlString :list-type :ul)))))