summaryrefslogtreecommitdiff
path: root/src/clarktown/parsers/quote_block.clj
blob: ff2dda8478f623a998b50c0871d10fe80f35fef6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(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))
                    (string/join "\n"))
        block (parser/parse blocks parsers)]
    (str "<blockquote>" block "</blockquote>")))