diff options
Diffstat (limited to 'src/clarktown/parsers/quote_block.clj')
| -rw-r--r-- | src/clarktown/parsers/quote_block.clj | 23 |
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>"))) |
