     (replace ">"  "&gt;")
     (replace "\"" "&quot;")))
 
+(defn quoted?
+  "True if the form is a quoted value."
+  [x]
+  (and (list? x)
+       (= 'quote (first x))))
+
 (defn literal?
-  "True if the value is a literal string, keyword, number, map, vector, nil
-  or a quoted value."
+  "True if the value is a not a list or a quoted value."
   [x]
-  (or (string? x)
-      (number? x)
-      (keyword? x)
-      (vector? x)
-      (map? x)
-      (nil? x)
-      (and (list? x)
-           (= (first x) 'quote))))
-
-(defn- pre-compile
-  "Pre-compile a form if its arguments are all literals."
-  [form]
-  (if (every? literal? (rest form))
-    (eval form)
-    (list form)))
+  (or (not (list? x))
+      (quoted? x)))
 
 (defn- format-attr
   "Turn a key-value pair into a pair of attribute-value strings."

  #"([^\s\.#]+)(?:#([^\s\.#]+))?(?:\.([^\s#]+))?"
  "Regular expression that parses a CSS-style id and class from a tag name.")

(defn make-start-tag
  "Create the start of a tag, given a tag name with optional CSS-style syntax
  to denote the id and classes."
  [tag]
  (let [[_ tag id classes] (re-matches re-tag (as-str tag))]
    (list "<" tag (make-attrs {:id id, :class classes}))))

(defn make-tag-attrs
  "Create the attributes for a tag, if the second element of the vector is a
  map."
  [attrs]
  (if (map? attrs)
    (list (make-attrs attrs))))

(defn make-end-tag
  "Create an ending tag."
  [tag]
  (list "</" (as-str tag) ">"))

(defn remove-attrs
  "Remove optional attribute map from content."
  [content]
  (if (map? (first content))
    (rest content)
    content))

(defmulti compile-html
  "Compile a Clojure data structure value to a seq of strings and forms."
  (fn [x] (type x)))

(defmethod compile-html IPersistentVector
  [[tag & content]]
  (concat
    (pre-compile `(make-start-tag ~tag))
    (pre-compile `(make-tag-attrs ~(first content)))
    (list ">")
    (mapcat compile-html (remove-attrs content))
    (pre-compile `(make-end-tag ~tag))))

(defmethod compile-html IPersistentList
  [form]
  form)

(defmethod compile-html :default
  [x]
  (list (pre-compile `(str ~x))))

(defn collapse-strs
  "Concatenate adjacent strings in a sequence."

(defn- make-attrs
  "Turn a map into a string of HTML attributes, sorted by attribute name."
  [attrs]
  (remove nil?
    (for [[attr value] (sort (map format-attr attrs))]
      (if attr
        (str " " attr "=\"" value "\"")))))
