(defn tag->html
"Returns an HTML string for the given tag description."
[tag]
(cond
(:delimiter? tag) "<span class='delimiter'>"
(:error? tag) (format
"<span class='error' data-message='%s'></span>"
(some-> (:message tag) escape-html-str))
(: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) "</span>"))