(defn tag->hiccup
"Returns a Hiccup-compatible data structure for the given tag description."
[tag]
(cond
(:delimiter? tag) [:span {:class "delimiter"}]
(:error? tag) [:span {:class "error" :data-message (:message tag)}]
(:begin? tag) (let [value (:value tag)]
(cond
(symbol? value) [:span {:class "symbol"}]
(list? value) [:span {:class "collection list"}]
(vector? value) [:span {:class "collection vector"}]
(map? value) [:span {:class "collection map"}]
(set? value) [:span {:class "collection set"}]
(number? value) [:span {:class "number"}]
(string? value) [:span {:class "string"}]
(keyword? value) [:span {:class "keyword"}]
(nil? value) [:span {:class "nil"}]
(contains? #{true false} value) [:span {:class "boolean"}]
:else [:span]))
(:end? tag) nil))