summaryrefslogtreecommitdiff
path: root/src/clarktown/parsers/quote_block.clj
blob: 8b9c997f145df6cf545e5120b788de85a0e75ef3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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>")))