implement indention

This commit is contained in:
jem 2018-05-18 20:47:15 +02:00
parent 12d4661db9
commit 535465c362
4 changed files with 99 additions and 6 deletions

View file

@ -96,7 +96,7 @@ more text"
some text
* List
## Heading 3
#### Heading 3
more text
some text
Simple content.

View file

@ -0,0 +1,35 @@
(ns smeagol.test.include.indent
(:require [clojure.test :refer :all]
[smeagol.include.indent :as sut]))
(deftest test-parse-heading
(testing
(is (= '(["# " "# " "" "# "])
(sut/parse-heading "# h1")))
(is (= '(["\n# " "\n# " "\n" "# "])
(sut/parse-heading "\n# h1")))))
(deftest test-indent-heading
(testing
(is (= "# h1"
(sut/do-indent-heading 0 "# h1")))
(is (= "### h1"
(sut/do-indent-heading 2 "# h1")))
(is (= "\n### h1"
(sut/do-indent-heading 2 "\n# h1")))))
(deftest test-parse-list
(testing
(is (= '([" * " " * " " " "* "])
(sut/parse-list " * list")))
(is (= '(["\n * " "\n * " "\n " "* "])
(sut/parse-list "\n * list")))))
(deftest test-indent-list
(testing
(is (= " * list"
(sut/do-indent-list 0 " * list")))
(is (= " * list"
(sut/do-indent-list 2 " * list")))
(is (= "\n * list"
(sut/do-indent-list 2 "\n * list")))))