Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn enlive->hiccup [node]
(if-not (map? node)
node
(let [{:keys [tag attrs content]} node
children (map enlive->hiccup content)]
(if (empty? attrs)
(vec (cons tag children))
(vec (cons tag (cons attrs children)))))))
(defn hiccup->enlive [node]
(if-not (vector? node)
node
(let [[tag & children] node
attrs (when (map? (first children))
(first children))
children (if attrs
(rest children)
children)]
{:tag tag
:attrs attrs
:content (map hiccup->enlive children)})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.