diff options
| -rw-r--r-- | src/clarktown/parser.clj | 15 | ||||
| -rw-r--r-- | src/clarktown/parsers/empty_block.clj | 2 | ||||
| -rw-r--r-- | test/clarktown/parsers/horizontal_line_block_test.clj | 7 | ||||
| -rw-r--r-- | test/clarktown/parsers/quote_block_test.clj | 15 |
4 files changed, 30 insertions, 9 deletions
diff --git a/src/clarktown/parser.clj b/src/clarktown/parser.clj index 0b6911d..afe9668 100644 --- a/src/clarktown/parser.clj +++ b/src/clarktown/parser.clj @@ -67,13 +67,14 @@ parsers (filter #(= nil (:matcher %)) parsers)] (if (empty? parsers) block - (loop [block block - renderers (:renderers (first parsers))] - (if (empty? renderers) - block - (let [renderer (first renderers)] - (recur (renderer block parsers) - (drop 1 renderers)))))))) + (recur (loop [block block + renderers (:renderers (first parsers))] + (if (empty? renderers) + block + (let [renderer (first renderers)] + (recur (renderer block parsers) + (drop 1 renderers))))) + (drop 1 parsers))))) (defn- parse-blocks diff --git a/src/clarktown/parsers/empty_block.clj b/src/clarktown/parsers/empty_block.clj index f16bf6a..0ed5a08 100644 --- a/src/clarktown/parsers/empty_block.clj +++ b/src/clarktown/parsers/empty_block.clj @@ -13,5 +13,5 @@ (defn render "Renders an empty block." - [block _] + [_ _] "") diff --git a/test/clarktown/parsers/horizontal_line_block_test.clj b/test/clarktown/parsers/horizontal_line_block_test.clj index c8c0e90..56601e2 100644 --- a/test/clarktown/parsers/horizontal_line_block_test.clj +++ b/test/clarktown/parsers/horizontal_line_block_test.clj @@ -7,4 +7,9 @@ (deftest horizontal-line-block-test (testing "Creating a horizontal line" (is (= "<hr>" - (horizontal-line-block/render "***" nil)))))
\ No newline at end of file + (horizontal-line-block/render "***" nil)))) + + (testing "Is a horizontal line block" + (is (true? (horizontal-line-block/is? "***"))) + (is (true? (horizontal-line-block/is? " ***"))) + (is (false? (horizontal-line-block/is? "Test *** 123")))))
\ No newline at end of file diff --git a/test/clarktown/parsers/quote_block_test.clj b/test/clarktown/parsers/quote_block_test.clj new file mode 100644 index 0000000..94553cf --- /dev/null +++ b/test/clarktown/parsers/quote_block_test.clj @@ -0,0 +1,15 @@ +(ns clarktown.parsers.quote-block-test + (:require + [clojure.test :refer [deftest testing is]] + [clarktown.parsers.quote-block :as quote-block])) + + +(deftest quote-block-block-test + (testing "Creating a quote block line" + (is (= (quote-block/render "> First line\n> second line" nil) + "<blockquote>First line\nsecond line</blockquote>"))) + + (testing "Checking a quote block" + (is (true? (quote-block/is? "> Test"))) + (is (true? (quote-block/is? " > Test"))) + (is (true? (quote-block/is? ">")))))
\ No newline at end of file |
