From 52203a49aa544b2c11c96445d8732893160c436b Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Tue, 19 Apr 2022 17:50:19 +0300 Subject: WIP #16 Pretty much done. Needs more testing. And new documentation. --- test/clarktown/renderers/heading_block_test.clj | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 test/clarktown/renderers/heading_block_test.clj (limited to 'test/clarktown/renderers/heading_block_test.clj') diff --git a/test/clarktown/renderers/heading_block_test.clj b/test/clarktown/renderers/heading_block_test.clj new file mode 100644 index 0000000..9c3386f --- /dev/null +++ b/test/clarktown/renderers/heading_block_test.clj @@ -0,0 +1,44 @@ +(ns clarktown.renderers.heading-block-test + (:require + [clojure.test :refer [deftest testing is]] + [clarktown.renderers.heading-block :as heading-block])) + + +(deftest atx-heading-renderer-test + (testing "Hashbang heading block that's a H1" + (is (= "

This is a heading block.

" + (heading-block/render "# This is a heading block." nil)))) + + (testing "Hashbang heading block that's a H2" + (is (= "

This is a heading block.

" + (heading-block/render "## This is a heading block." nil)))) + + (testing "Hashbang heading block that's a H3" + (is (= "

This is a heading block.

" + (heading-block/render "### This is a heading block." nil)))) + + (testing "Hashbang heading block that's a H4" + (is (= "

This is a heading block.

" + (heading-block/render "#### This is a heading block." nil)))) + + (testing "Hashbang heading block that's a H5" + (is (= "
This is a heading block.
" + (heading-block/render "##### This is a heading block." nil))))) + + +(deftest settext-heading-renderer-text + (testing "Settext heading block that's a H1" + (is (= "

This is a heading block.

" + (heading-block/render "This is a heading block.\n=========" nil)))) + + (testing "Settext heading block that's a H1 spanning multiple lines" + (is (= "

This is a \nheading block spanning multiple lines.

" + (heading-block/render "This is a \nheading block spanning multiple lines.\n========" nil)))) + + (testing "Settext heading block that's a H2" + (is (= "

This is a heading block.

" + (heading-block/render "This is a heading block.\n---------" nil)))) + + (testing "Settext heading block that's a H2 spanning multiple lines" + (is (= "

This is a \nheading block spanning multiple lines.

" + (heading-block/render "This is a \nheading block spanning multiple lines.\n--------" nil))))) \ No newline at end of file -- cgit v1.2.3 From 04821d8be5d773153718948454c864495704f67b Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Thu, 21 Apr 2022 19:13:02 +0300 Subject: Send correctors to each render as well --- src/clarktown/core.clj | 143 +-------------------- src/clarktown/correctors.clj | 8 +- src/clarktown/engine.clj | 140 ++++++++++++++++++++ src/clarktown/renderers/bold.clj | 2 +- src/clarktown/renderers/code_block.clj | 2 +- src/clarktown/renderers/empty_block.clj | 2 +- src/clarktown/renderers/heading_block.clj | 2 +- src/clarktown/renderers/horizontal_line_block.clj | 2 +- src/clarktown/renderers/inline_code.clj | 2 +- src/clarktown/renderers/italic.clj | 2 +- src/clarktown/renderers/link_and_image.clj | 2 +- src/clarktown/renderers/list_block.clj | 4 +- src/clarktown/renderers/paragraph_block.clj | 2 +- src/clarktown/renderers/quote_block.clj | 6 +- src/clarktown/renderers/strikethrough.clj | 2 +- test/clarktown/renderers/bold_test.clj | 6 +- test/clarktown/renderers/code_block_test.clj | 4 +- test/clarktown/renderers/empty_block_test.clj | 2 +- test/clarktown/renderers/heading_block_test.clj | 18 +-- .../renderers/horizontal_line_block_test.clj | 4 +- test/clarktown/renderers/inline_code_test.clj | 4 +- test/clarktown/renderers/italic_test.clj | 6 +- test/clarktown/renderers/link_and_image_test.clj | 10 +- test/clarktown/renderers/quote_block_test.clj | 2 +- test/clarktown/renderers/strikethrough_test.clj | 4 +- 25 files changed, 194 insertions(+), 187 deletions(-) create mode 100644 src/clarktown/engine.clj (limited to 'test/clarktown/renderers/heading_block_test.clj') diff --git a/src/clarktown/core.clj b/src/clarktown/core.clj index cabd6e6..a624275 100644 --- a/src/clarktown/core.clj +++ b/src/clarktown/core.clj @@ -1,147 +1,10 @@ (ns clarktown.core (:require - [clojure.string :as string] + [clarktown.engine :as engine] [clarktown.parsers :as parsers] [clarktown.correctors :as correctors])) -(defn- stitch-code-blocks - "Since code blocks can span multiple blocks (a block is separated by - two line breaks from another block) , we need to stitch them together - into one block in order for a block parser to be able to do anything - with it." - [blocks] - (loop [stitched-blocks [] - code-block-started? false - blocks blocks] - (if (empty? blocks) - stitched-blocks - (let [block (first blocks)] - (if (and (string/starts-with? (string/trim block) "```") - (not (string/ends-with? (string/trim block) "```"))) - (recur (conj stitched-blocks block) - true - (drop 1 blocks)) - (if code-block-started? - (let [last-block (last stitched-blocks) - last-block-index (- (count stitched-blocks) 1)] - (if (string/ends-with? (string/trim block) "```") - (recur (assoc stitched-blocks last-block-index (str last-block "\n\n" block)) - false - (drop 1 blocks)) - (recur (assoc stitched-blocks last-block-index (str last-block "\n\n" block)) - true - (drop 1 blocks)))) - (recur (conj stitched-blocks block) - false - (drop 1 blocks)))))))) - - -(defn- correct-block-separations - "Corrects block separations and adds newlines above or - below a block where needed." - [correctors lines] - (->> lines - (map-indexed - (fn [index line] - (let [add-line-above? (some #(true? (% lines line index)) (:empty-line-above? correctors)) - add-line-below? (some #(true? (% lines line index)) (:empty-line-below? correctors))] - (cond - ; If code block starts but there is no empty newline - ; above, let's fix that - (and add-line-above? - (not add-line-below?)) - (str \newline line) - - ; If the code block ends, but there is no empty newline - ; below, let's fix that. - (and add-line-below? - (not add-line-above?)) - (str line \newline) - - ; If the code block needs a newline both above and below, - ; let's fix that. - (and add-line-above? - add-line-below?) - (str \newline line \newline) - - ; otherwise is what it is - :else line)))))) - - -(defn- correct-markdown - "Corrects invalid Markdown for the parser." - [markdown given-correctors] - (let [lines (string/split-lines markdown)] - (->> lines - (correct-block-separations (:block-separations given-correctors)) - (string/join \newline)))) - - -(defn- find-parser-by-block - "Find a parser from `parsers` that matches the given `block`." - [parsers block] - (->> parsers - (filter - (fn [{:keys [matcher]}] - (when matcher - (matcher block)))) - first)) - - -(defn- parse-block-with-known-parser - "Parses a given `block` with a known `parser`." - [parser parsers block] - (loop [block block - renderers (:renderers parser)] - (if (empty? renderers) - block - (let [renderer (first renderers)] - (recur (renderer block parsers) - (drop 1 renderers)))))) - - -(defn- parse-block-with-unknown-parsers - "Parses the given `block` with all the parsers that do not have - a matcher function, useful for any fallback parsing one might want - to do." - [parsers block] - (loop [block block - parsers (filter #(= nil (:matcher %)) parsers)] - (if (empty? parsers) - block - (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 - "Parses each individual Markdown block, given as `blocks`, with - the list of `parsers`." - [blocks parsers] - (for [block blocks] - (if-let [parser (find-parser-by-block parsers block)] - (->> (string/trim block) - (parse-block-with-known-parser parser parsers)) - (->> (string/trim block) - (parse-block-with-unknown-parsers parsers))))) - - -(defn parse - "Parses given `markdown` with `parsers`." - [markdown given-parsers given-correctors] - (let [blocks (-> (correct-markdown markdown given-correctors) - (string/split #"\n\n") - stitch-code-blocks) - parsed-blocks (parse-blocks blocks given-parsers)] - (string/join "\n\n" parsed-blocks))) - - (defn render "Renders the given `markdown` into a consumable HTML form. Optionally, a second argument can be passed that is made out of a vector of parsers. @@ -155,7 +18,7 @@ argument, which is a given Markdown block. An example parser: - ``` + ```clojure {:matcher (fn [block] ...) :renderers [(fn [block] ...) (fn [block] ...)]} ```" @@ -164,4 +27,4 @@ ([markdown given-parsers] (render markdown given-parsers correctors/default-correctors)) ([markdown given-parsers given-correctors] - (parse markdown given-parsers given-correctors))) \ No newline at end of file + (engine/render markdown given-parsers given-correctors))) \ No newline at end of file diff --git a/src/clarktown/correctors.clj b/src/clarktown/correctors.clj index d97defa..14d82ca 100644 --- a/src/clarktown/correctors.clj +++ b/src/clarktown/correctors.clj @@ -4,7 +4,9 @@ [clarktown.correctors.atx-heading-block :as atx-heading-block])) -(def default-block-separation-correctors +(def + ^{:doc "The default block separation correctors."} + default-block-separation-correctors {:empty-line-above? [code-block/empty-line-above? atx-heading-block/empty-line-above?] @@ -13,5 +15,7 @@ atx-heading-block/empty-line-below?]}) -(def default-correctors +(def + ^{:doc "The default correctors."} + default-correctors {:block-separations default-block-separation-correctors}) \ No newline at end of file diff --git a/src/clarktown/engine.clj b/src/clarktown/engine.clj new file mode 100644 index 0000000..17e5867 --- /dev/null +++ b/src/clarktown/engine.clj @@ -0,0 +1,140 @@ +(ns clarktown.engine + (:require + [clojure.string :as string])) + + +(defn- stitch-code-blocks + "Since code blocks can span multiple blocks (a block is separated by + two line breaks from another block) , we need to stitch them together + into one block in order for a block parser to be able to do anything + with it." + [blocks] + (loop [stitched-blocks [] + code-block-started? false + blocks blocks] + (if (empty? blocks) + stitched-blocks + (let [block (first blocks)] + (if (and (string/starts-with? (string/trim block) "```") + (not (string/ends-with? (string/trim block) "```"))) + (recur (conj stitched-blocks block) + true + (drop 1 blocks)) + (if code-block-started? + (let [last-block (last stitched-blocks) + last-block-index (- (count stitched-blocks) 1)] + (if (string/ends-with? (string/trim block) "```") + (recur (assoc stitched-blocks last-block-index (str last-block "\n\n" block)) + false + (drop 1 blocks)) + (recur (assoc stitched-blocks last-block-index (str last-block "\n\n" block)) + true + (drop 1 blocks)))) + (recur (conj stitched-blocks block) + false + (drop 1 blocks)))))))) + + +(defn- correct-block-separations + "Corrects block separations and adds newlines above or + below a block where needed." + [correctors lines] + (->> lines + (map-indexed + (fn [index line] + (let [add-line-above? (some #(true? (% lines line index)) (:empty-line-above? correctors)) + add-line-below? (some #(true? (% lines line index)) (:empty-line-below? correctors))] + (cond + ; If code block starts but there is no empty newline + ; above, let's fix that + (and add-line-above? + (not add-line-below?)) + (str \newline line) + + ; If the code block ends, but there is no empty newline + ; below, let's fix that. + (and add-line-below? + (not add-line-above?)) + (str line \newline) + + ; If the code block needs a newline both above and below, + ; let's fix that. + (and add-line-above? + add-line-below?) + (str \newline line \newline) + + ; otherwise is what it is + :else line)))))) + + +(defn- correct-markdown + "Corrects invalid Markdown for the parser." + [markdown given-correctors] + (let [lines (string/split-lines markdown)] + (->> lines + (correct-block-separations (:block-separations given-correctors)) + (string/join \newline)))) + + +(defn- find-parser-by-block + "Find a parser from `parsers` that matches the given `block`." + [parsers block] + (->> parsers + (filter + (fn [{:keys [matcher]}] + (when matcher + (matcher block)))) + first)) + + +(defn- parse-block-with-known-parser + "Parses a given `block` with a known `parser`." + [parser given-parsers given-correctors block] + (loop [block block + renderers (:renderers parser)] + (if (empty? renderers) + block + (let [renderer (first renderers)] + (recur (renderer block given-parsers given-correctors) + (drop 1 renderers)))))) + + +(defn- parse-block-with-unknown-parsers + "Parses the given `block` with all the parsers that do not have + a matcher function, useful for any fallback parsing one might want + to do." + [given-parsers given-correctors block] + (loop [block block + parsers (filter #(= nil (:matcher %)) given-parsers)] + (if (empty? parsers) + block + (recur (loop [block block + renderers (:renderers (first parsers))] + (if (empty? renderers) + block + (let [renderer (first renderers)] + (recur (renderer block parsers given-correctors) + (drop 1 renderers))))) + (drop 1 parsers))))) + + +(defn- parse-blocks + "Parses each individual Markdown block, given as `blocks`, with + the list of `parsers`." + [blocks given-parsers given-correctors] + (for [block blocks] + (if-let [parser (find-parser-by-block given-parsers block)] + (->> (string/trim block) + (parse-block-with-known-parser parser given-parsers given-correctors)) + (->> (string/trim block) + (parse-block-with-unknown-parsers given-parsers given-correctors))))) + + +(defn render + "Parses given `markdown` with `parsers`." + [markdown given-parsers given-correctors] + (let [blocks (-> (correct-markdown markdown given-correctors) + (string/split #"\n\n") + stitch-code-blocks) + parsed-blocks (parse-blocks blocks given-parsers given-correctors)] + (string/join "\n\n" parsed-blocks))) \ No newline at end of file diff --git a/src/clarktown/renderers/bold.clj b/src/clarktown/renderers/bold.clj index 1ce7f84..64d6137 100644 --- a/src/clarktown/renderers/bold.clj +++ b/src/clarktown/renderers/bold.clj @@ -5,7 +5,7 @@ (defn render "Renders all occurring bold text as bold." - [block _] + [block _ _] (loop [block block matches (-> (re-seq #"(\*{2}|\_{2})[^\*|\_](.*?)[^\*|\_](\*{2}|\_{2})" block) distinct)] diff --git a/src/clarktown/renderers/code_block.clj b/src/clarktown/renderers/code_block.clj index 2bed4e6..184e90e 100644 --- a/src/clarktown/renderers/code_block.clj +++ b/src/clarktown/renderers/code_block.clj @@ -5,7 +5,7 @@ (defn render "Renders the code block." - [block _] + [block _ _] (let [language (->> block (re-find #"\`\`\`(\w+)") second) diff --git a/src/clarktown/renderers/empty_block.clj b/src/clarktown/renderers/empty_block.clj index 66e819e..84df1fb 100644 --- a/src/clarktown/renderers/empty_block.clj +++ b/src/clarktown/renderers/empty_block.clj @@ -3,5 +3,5 @@ (defn render "Renders an empty block." - [_ _] + [_ _ _] "") diff --git a/src/clarktown/renderers/heading_block.clj b/src/clarktown/renderers/heading_block.clj index f953d0a..4da9bda 100644 --- a/src/clarktown/renderers/heading_block.clj +++ b/src/clarktown/renderers/heading_block.clj @@ -38,7 +38,7 @@ (defn render "Renders the heading block." - [block _] + [block _ _] (if (matcher/is-atx-heading? block) (render-atx-heading block) (render-settext-heading block))) diff --git a/src/clarktown/renderers/horizontal_line_block.clj b/src/clarktown/renderers/horizontal_line_block.clj index f141e5f..14e5d8a 100644 --- a/src/clarktown/renderers/horizontal_line_block.clj +++ b/src/clarktown/renderers/horizontal_line_block.clj @@ -3,5 +3,5 @@ (defn render "Renders the horizontal line block." - [_ _] + [_ _ _] "
") diff --git a/src/clarktown/renderers/inline_code.clj b/src/clarktown/renderers/inline_code.clj index 29593a8..e8c298f 100644 --- a/src/clarktown/renderers/inline_code.clj +++ b/src/clarktown/renderers/inline_code.clj @@ -5,7 +5,7 @@ (defn render "Renders all occurring inline code." - [block _] + [block _ _] (loop [block block matches (-> (re-seq #"\`.*?\`" block) distinct)] diff --git a/src/clarktown/renderers/italic.clj b/src/clarktown/renderers/italic.clj index a1568f6..970364e 100644 --- a/src/clarktown/renderers/italic.clj +++ b/src/clarktown/renderers/italic.clj @@ -5,7 +5,7 @@ (defn render "Renders all occurring italic text as italic." - [block _] + [block _ _] (loop [block block matches (-> (re-seq #"(\*{1,}?|\_{1,}?)(.*?)(\*{1,}?|\_{1,}?)" block) distinct)] diff --git a/src/clarktown/renderers/link_and_image.clj b/src/clarktown/renderers/link_and_image.clj index ea4a006..e61503e 100644 --- a/src/clarktown/renderers/link_and_image.clj +++ b/src/clarktown/renderers/link_and_image.clj @@ -11,7 +11,7 @@ (defn render "Renders all occurring links and images." - [block _] + [block _ _] (loop [block block matches (-> (re-seq #"\!?\[([a-zA-Z0-9\-\.\,]+( [a-zA-Z0-9\-\.\,]+)*)\]\((.*?)\)" block) distinct)] diff --git a/src/clarktown/renderers/list_block.clj b/src/clarktown/renderers/list_block.clj index 2a40b06..27ca72a 100644 --- a/src/clarktown/renderers/list_block.clj +++ b/src/clarktown/renderers/list_block.clj @@ -116,6 +116,6 @@ (defn render "Renders the list block" - [block _] + [block _ _] (-> (compose-item-tree block) - (render-items))) \ No newline at end of file + (render-items))) diff --git a/src/clarktown/renderers/paragraph_block.clj b/src/clarktown/renderers/paragraph_block.clj index c7bec22..0ab3788 100644 --- a/src/clarktown/renderers/paragraph_block.clj +++ b/src/clarktown/renderers/paragraph_block.clj @@ -5,5 +5,5 @@ (defn render "Renders the paragraph block." - [block _] + [block _ _] (str "

" (string/trim block) "

")) diff --git a/src/clarktown/renderers/quote_block.clj b/src/clarktown/renderers/quote_block.clj index ee30635..1a302f9 100644 --- a/src/clarktown/renderers/quote_block.clj +++ b/src/clarktown/renderers/quote_block.clj @@ -1,16 +1,16 @@ (ns clarktown.renderers.quote-block (:require [clojure.string :as string] - [clarktown.parser :as parser])) + [clarktown.engine :as engine])) (defn render "Renders a quote block." - [block parsers] + [block parsers correctors] (let [matches (re-seq #">.*" block) blocks (->> (for [match matches] (-> (subs match 1) string/trim)) (string/join "\n")) - block (parser/parse blocks parsers)] + block (engine/render blocks parsers correctors)] (str "
" block "
"))) diff --git a/src/clarktown/renderers/strikethrough.clj b/src/clarktown/renderers/strikethrough.clj index 8e124a0..133be47 100644 --- a/src/clarktown/renderers/strikethrough.clj +++ b/src/clarktown/renderers/strikethrough.clj @@ -5,7 +5,7 @@ (defn render "Renders all occurring strikethrough text." - [block _] + [block _ _] (loop [block block matches (-> (re-seq #"~~.*?~~" block) distinct)] diff --git a/test/clarktown/renderers/bold_test.clj b/test/clarktown/renderers/bold_test.clj index fba0ea6..28d9da8 100644 --- a/test/clarktown/renderers/bold_test.clj +++ b/test/clarktown/renderers/bold_test.clj @@ -7,12 +7,12 @@ (deftest bold-renderer-test (testing "Creating bold text with two surrounding asterisk characters" (is (= "This is bold." - (bold/render "**This is bold.**" nil)))) + (bold/render "**This is bold.**" nil nil)))) (testing "Creating bold text with two surrounding underscore characters" (is (= "This is bold." - (bold/render "__This is bold.__" nil)))) + (bold/render "__This is bold.__" nil nil)))) (testing "Creating bold text with both underscores and asterisks mixed" (is (= "Hi, my name is John, what is your name?" - (bold/render "Hi, my name is **John**, what is __your name?__" nil))))) \ No newline at end of file + (bold/render "Hi, my name is **John**, what is __your name?__" nil nil))))) \ No newline at end of file diff --git a/test/clarktown/renderers/code_block_test.clj b/test/clarktown/renderers/code_block_test.clj index 37c701b..c5779be 100644 --- a/test/clarktown/renderers/code_block_test.clj +++ b/test/clarktown/renderers/code_block_test.clj @@ -8,8 +8,8 @@ (deftest code-block-renderer-test (testing "Code block with language specification" (is (= (slurp (io/file (io/resource "test/parsers/code_block_result.html"))) - (code-block/render (slurp (io/file (io/resource "test/parsers/code_block.md"))) nil)))) + (code-block/render (slurp (io/file (io/resource "test/parsers/code_block.md"))) nil nil)))) (testing "Code block with NO language specification" (is (= (slurp (io/file (io/resource "test/parsers/code_block_no_language_result.html"))) - (code-block/render (slurp (io/file (io/resource "test/parsers/code_block_no_language.md"))) nil))))) \ No newline at end of file + (code-block/render (slurp (io/file (io/resource "test/parsers/code_block_no_language.md"))) nil nil))))) \ No newline at end of file diff --git a/test/clarktown/renderers/empty_block_test.clj b/test/clarktown/renderers/empty_block_test.clj index 35fb902..da0fc7c 100644 --- a/test/clarktown/renderers/empty_block_test.clj +++ b/test/clarktown/renderers/empty_block_test.clj @@ -6,5 +6,5 @@ (deftest empty-block-renderer-test (testing "Rendering an empty block" - (is (= (empty-block/render "" nil) + (is (= (empty-block/render "" nil nil) "")))) diff --git a/test/clarktown/renderers/heading_block_test.clj b/test/clarktown/renderers/heading_block_test.clj index 9c3386f..2196422 100644 --- a/test/clarktown/renderers/heading_block_test.clj +++ b/test/clarktown/renderers/heading_block_test.clj @@ -7,38 +7,38 @@ (deftest atx-heading-renderer-test (testing "Hashbang heading block that's a H1" (is (= "

This is a heading block.

" - (heading-block/render "# This is a heading block." nil)))) + (heading-block/render "# This is a heading block." nil nil)))) (testing "Hashbang heading block that's a H2" (is (= "

This is a heading block.

" - (heading-block/render "## This is a heading block." nil)))) + (heading-block/render "## This is a heading block." nil nil)))) (testing "Hashbang heading block that's a H3" (is (= "

This is a heading block.

" - (heading-block/render "### This is a heading block." nil)))) + (heading-block/render "### This is a heading block." nil nil)))) (testing "Hashbang heading block that's a H4" (is (= "

This is a heading block.

" - (heading-block/render "#### This is a heading block." nil)))) + (heading-block/render "#### This is a heading block." nil nil)))) (testing "Hashbang heading block that's a H5" (is (= "
This is a heading block.
" - (heading-block/render "##### This is a heading block." nil))))) + (heading-block/render "##### This is a heading block." nil nil))))) (deftest settext-heading-renderer-text (testing "Settext heading block that's a H1" (is (= "

This is a heading block.

" - (heading-block/render "This is a heading block.\n=========" nil)))) + (heading-block/render "This is a heading block.\n=========" nil nil)))) (testing "Settext heading block that's a H1 spanning multiple lines" (is (= "

This is a \nheading block spanning multiple lines.

" - (heading-block/render "This is a \nheading block spanning multiple lines.\n========" nil)))) + (heading-block/render "This is a \nheading block spanning multiple lines.\n========" nil nil)))) (testing "Settext heading block that's a H2" (is (= "

This is a heading block.

" - (heading-block/render "This is a heading block.\n---------" nil)))) + (heading-block/render "This is a heading block.\n---------" nil nil)))) (testing "Settext heading block that's a H2 spanning multiple lines" (is (= "

This is a \nheading block spanning multiple lines.

" - (heading-block/render "This is a \nheading block spanning multiple lines.\n--------" nil))))) \ No newline at end of file + (heading-block/render "This is a \nheading block spanning multiple lines.\n--------" nil nil))))) \ No newline at end of file diff --git a/test/clarktown/renderers/horizontal_line_block_test.clj b/test/clarktown/renderers/horizontal_line_block_test.clj index db72682..9b23607 100644 --- a/test/clarktown/renderers/horizontal_line_block_test.clj +++ b/test/clarktown/renderers/horizontal_line_block_test.clj @@ -6,8 +6,8 @@ (deftest horizontal-line-block-renderer-test (testing "Creating a horizontal line" - (is (= (horizontal-line-block/render "***" nil) + (is (= (horizontal-line-block/render "***" nil nil) "
")) - (is (= (horizontal-line-block/render "---" nil) + (is (= (horizontal-line-block/render "---" nil nil) "
")))) diff --git a/test/clarktown/renderers/inline_code_test.clj b/test/clarktown/renderers/inline_code_test.clj index 2071b7f..b1b277e 100644 --- a/test/clarktown/renderers/inline_code_test.clj +++ b/test/clarktown/renderers/inline_code_test.clj @@ -7,8 +7,8 @@ (deftest inline-code-renderer-test (testing "Creating inline code text" (is (= "This is inline code." - (inline-code/render "`This is inline code.`" nil)))) + (inline-code/render "`This is inline code.`" nil nil)))) (testing "Creating inline-code text in the middle of regular text" (is (= "This is regular text, mixed with some inline code., and it's great." - (inline-code/render "This is regular text, mixed with `some inline code.`, and it's great." nil))))) \ No newline at end of file + (inline-code/render "This is regular text, mixed with `some inline code.`, and it's great." nil nil))))) \ No newline at end of file diff --git a/test/clarktown/renderers/italic_test.clj b/test/clarktown/renderers/italic_test.clj index 29e7811..e85ee36 100644 --- a/test/clarktown/renderers/italic_test.clj +++ b/test/clarktown/renderers/italic_test.clj @@ -7,12 +7,12 @@ (deftest italic-renderer-test (testing "Creating italic text with one surrounding asterisk character" (is (= "This is italic." - (italic/render "*This is italic.*" nil)))) + (italic/render "*This is italic.*" nil nil)))) (testing "Creating italic text with one surrounding underscore character" (is (= "This is italic." - (italic/render "_This is italic._" nil)))) + (italic/render "_This is italic._" nil nil)))) (testing "Creating italic text with both underscores and asterisks mixed" (is (= "Hi, my name is John, what is your name?" - (italic/render "Hi, my name is *John*, what is _your name?_" nil))))) \ No newline at end of file + (italic/render "Hi, my name is *John*, what is _your name?_" nil nil))))) \ No newline at end of file diff --git a/test/clarktown/renderers/link_and_image_test.clj b/test/clarktown/renderers/link_and_image_test.clj index aa821e3..d17e070 100644 --- a/test/clarktown/renderers/link_and_image_test.clj +++ b/test/clarktown/renderers/link_and_image_test.clj @@ -6,18 +6,18 @@ (deftest link-renderer-test (testing "Creating a link" - (is (= (link-and-image/render "[This is a link](https://example.com)" nil) + (is (= (link-and-image/render "[This is a link](https://example.com)" nil nil) "This is a link")) - (is (= (link-and-image/render "[This-is-a-link](https://example.com)" nil) + (is (= (link-and-image/render "[This-is-a-link](https://example.com)" nil nil) "This-is-a-link")) - (is (= (link-and-image/render "[x] [label](link)" nil) + (is (= (link-and-image/render "[x] [label](link)" nil nil) "[x] label")) - (is (= (link-and-image/render "[ ] [label](link)" nil) + (is (= (link-and-image/render "[ ] [label](link)" nil nil) "[ ] label"))) (testing "Creating an image" - (is (= (link-and-image/render "![This is an image](https://example.com)" nil) + (is (= (link-and-image/render "![This is an image](https://example.com)" nil nil) "\"This")))) \ No newline at end of file diff --git a/test/clarktown/renderers/quote_block_test.clj b/test/clarktown/renderers/quote_block_test.clj index 33a7495..1065a85 100644 --- a/test/clarktown/renderers/quote_block_test.clj +++ b/test/clarktown/renderers/quote_block_test.clj @@ -6,5 +6,5 @@ (deftest quote-block-block-renderer-test (testing "Creating a quote block line" - (is (= (quote-block/render "> First line\n> second line" nil) + (is (= (quote-block/render "> First line\n> second line" nil nil) "
First line\nsecond line
")))) \ No newline at end of file diff --git a/test/clarktown/renderers/strikethrough_test.clj b/test/clarktown/renderers/strikethrough_test.clj index 55493e0..cf08fc9 100644 --- a/test/clarktown/renderers/strikethrough_test.clj +++ b/test/clarktown/renderers/strikethrough_test.clj @@ -6,9 +6,9 @@ (deftest strikethrough-renderer-test (testing "Creating strikethrough text" - (is (= (strikethrough/render "~~This is strikethrough text.~~" nil) + (is (= (strikethrough/render "~~This is strikethrough text.~~" nil nil) "This is strikethrough text."))) (testing "Creating strikethrough text mixed with regular text" - (is (= (strikethrough/render "Some other text, ~~This is strikethrough text.~~ And more text." nil) + (is (= (strikethrough/render "Some other text, ~~This is strikethrough text.~~ And more text." nil nil) "Some other text, This is strikethrough text. And more text.")))) \ No newline at end of file -- cgit v1.2.3