 	(invoke [this x] (.applyTo this (list x)))
 	(applyTo [this args] (let [tag (first args)] (tag this))))
 
-(impl-invoke (defrecord Tag [tag-name attrs css items]
+(defrecord-ifn Tag [tag-name attrs css items]
 	java.lang.Object
 	(toString [_]
 		(let [attrs-with-css (if (empty? css) attrs (assoc attrs :style (str css)))]


(defn- $lift [& fs] (partial map #(%1 %2) fs))

(defmacro impl-invoke [record]
	(let [parted-record (partition-by #(= % 'clojure.lang.IFn) record)
	      paramses (map (fn [n] (map #(symbol (str "_" %)) (range 0 n))) (range 0 21))]
		(concat
			(apply concat (take 2 parted-record))
			(map (fn [params] `(~'invoke [~'this ~@params] (.applyTo ~'this (list ~@params)))) paramses)
			(list `(~'invoke [~'this ~@(last paramses) ~'more] (.applyTo ~'this (concat (list ~@(last paramses)) ~'more))))

;; Character Entities

(defmacro defentity
	([id] `(defentity ~id ~id))
	([id value] `(def ~id (literal ~(str "&" (name value) ";")))))

(defentity nbsp)
