diff --git a/src/cryogen_core/toc.clj b/src/cryogen_core/toc.clj index e7bc348..f40cd35 100644 --- a/src/cryogen_core/toc.clj +++ b/src/cryogen_core/toc.clj @@ -99,7 +99,8 @@ contents, while :ul will result in an unordered list. The default is an ordered list." [^String html & {:keys [list-type] :or {list-type :ol}}] - (-> html + (let [list-type (if (true? list-type) :ol list-type)] + (-> html (.getBytes "UTF-8") (java.io.ByteArrayInputStream.) (html/parse) @@ -107,4 +108,4 @@ (get-headings) (build-toc-tree) (build-toc list-type) - (hiccup/html))) + (hiccup/html)))) diff --git a/test/cryogen_core/toc_test.clj b/test/cryogen_core/toc_test.clj index 4554205..4a608e9 100644 --- a/test/cryogen_core/toc_test.clj +++ b/test/cryogen_core/toc_test.clj @@ -93,3 +93,17 @@ "but outer headers cannot be less indented " "than the original header."])) )) + + +(deftest test-generate-toc + (let [htmlString "

Test

"] + (is (= "
  1. Test
" + (generate-toc htmlString))) + (is (= "
  1. Test
" + (generate-toc htmlString :list-type true))) + (is (= "
  1. Test
" + (generate-toc htmlString :list-type :ol))) + (is (= "" + (generate-toc htmlString :list-type :ul))))) + +