3 [clojure.string :as str]
4 [clojure.walk :as walk]
5 [gemtext.core :as gemtext]))
8 "Given a string representing a gemtext document, parse it into an
9 hiccup-like data structure."
14 (gemtext/unparse thing))
16 (defn maybe-patch-link [[type attrs body :as t]]
17 (cond (not= type :a) t
19 (re-matches #".*\.(jpg|jpeg|png|gif)" (:href attrs))
20 (let [{:keys [href]} attrs]
27 (re-matches #".*\.gmi" (:href attrs))
28 [:p.link [:a {:href (str/replace (:href attrs)
34 [:p.link [:a {:href (:href attrs)}
37 (defn not-empty-ps [[type body :as t]]
43 (->> (gemtext/to-hiccup doc)
45 (map maybe-patch-link)))
48 (to-hiccup [[:link "http://f.com" "hello"]])