summaryrefslogtreecommitdiff
path: root/src/clarktown/parsers/quote_block.clj
diff options
context:
space:
mode:
authorAsko Nõmm <asko@bien.ee>2021-12-07 21:38:01 -0300
committerAsko Nõmm <asko@bien.ee>2021-12-07 21:38:01 -0300
commit0faad35a2bb98eda9aa59dc6b95bb1978f3fda71 (patch)
treed6c95cfabf4de31ee362c0fc51643009a709b49f /src/clarktown/parsers/quote_block.clj
parent3099a0f7cc132a15c4ea1114937c34c07f751318 (diff)
Pass renderers down to parsers for potential recursiveness and add quote block
Diffstat (limited to 'src/clarktown/parsers/quote_block.clj')
-rw-r--r--src/clarktown/parsers/quote_block.clj23
1 files changed, 23 insertions, 0 deletions
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 "<blockquote>" (string/join "\n" blocks) "</blockquote>")))