From 0faad35a2bb98eda9aa59dc6b95bb1978f3fda71 Mon Sep 17 00:00:00 2001 From: Asko Nõmm Date: Tue, 7 Dec 2021 21:38:01 -0300 Subject: Pass renderers down to parsers for potential recursiveness and add quote block --- src/clarktown/parsers/quote_block.clj | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/clarktown/parsers/quote_block.clj (limited to 'src/clarktown/parsers/quote_block.clj') diff --git a/src/clarktown/parsers/quote_block.clj b/src/clarktown/parsers/quote_block.clj new file mode 100644 index 0000000..8b9c997 --- /dev/null +++ b/src/clarktown/parsers/quote_block.clj @@ -0,0 +1,23 @@ +(ns clarktown.parsers.quote-block + (:require + [clojure.string :as string] + [clarktown.parser :as parser])) + + +(defn is? + "Determines whether the given block is a quote block." + [block] + (-> (string/replace block #"\n" "") + string/trim + (string/starts-with? ">"))) + + +(defn render + "Renders a quote block." + [block parsers] + (let [matches (re-seq #">.*" block) + blocks (for [match matches] + (-> (subs match 1) + string/trim + (parser/parse parsers)))] + (str "
" (string/join "\n" blocks) "
"))) -- cgit v1.2.3