summaryrefslogtreecommitdiff
path: root/src/clarktown/parsers/link_and_image.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/clarktown/parsers/link_and_image.clj')
-rw-r--r--src/clarktown/parsers/link_and_image.clj27
1 files changed, 0 insertions, 27 deletions
diff --git a/src/clarktown/parsers/link_and_image.clj b/src/clarktown/parsers/link_and_image.clj
deleted file mode 100644
index 3be2efe..0000000
--- a/src/clarktown/parsers/link_and_image.clj
+++ /dev/null
@@ -1,27 +0,0 @@
-(ns clarktown.parsers.link-and-image
- (:require
- [clojure.string :as string]))
-
-
-(defn encode-href
- [href]
- (-> href
- (string/replace "_" "_")))
-
-
-(defn render
- "Renders all occurring links and images."
- [block _]
- (loop [block block
- matches (-> (re-seq #"\!?\[([a-zA-Z0-9\-\.\,]+( [a-zA-Z0-9\-\.\,]+)*)\]\((.*?)\)" block)
- distinct)]
- (if (empty? matches)
- block
- (let [[whole-match label _ href] (first matches)
- image? (string/starts-with? whole-match "!")
- image (str "<img src=\"" (encode-href href) "\" alt=\"" label "\">")
- link (str "<a href=\"" (encode-href href) "\">" label "</a>")]
- (recur (if image?
- (string/replace block whole-match image)
- (string/replace block whole-match link))
- (drop 1 matches)))))) \ No newline at end of file