You can get the following structure html-resourcefrom enlive :
{:tag :html :attrs {} :content []}
Then move it and turn it into a hiccup structure.
(defn html->hiccup
[html]
(if-not (string? html)
(->> (map html->hiccup (:content html))
(concat [(:tag html) (:attrs html)])
(keep identity)
vec)
html))
Here is a usage example:
user=> (html->hiccup {:tag :p
:content ["Hello" {:tag :a
:attrs {:href "/foo"}
:content ["World"]}
"!"]})
[:p "Hello" [:a {:href "/foo"} "World"] "!"]
source
share