 
 (defn get-in-metadata [k metadata]
   (k (first (filter #(k %) metadata))))
+
+(defn walk-tx-fn [wrap-node process-node]
+  (fn walk [tx]
+    (let [{metadata :arb/metadata, nodes :arb/value} tx]
+      (clojure.pprint/pprint {:metadata metadata, :nodes nodes})
+      (wrap-node
+       metadata
+       (apply vector (for [node nodes]
+                       (if (:content/text node)
+                         (process-node node)
+                         (walk node))))))))
+
+(defn tx->html [tx]
+  (-> tx (tx->arb) (arb->hiccup) (html)))
+
+(defn tx->arb [tx]
+  (let [process-node #(:content/text %)
+        wrap-node    #(vec
+                       (concat
+                        [:arb {:original-tag (get-in-metadata :metadata/html-tag %1)}]
+                        %2))
+        convert      (walk-tx-fn wrap-node process-node)]
+    (convert tx)))
 
 (defn walk-arb-fn [wrap-node process-node]
   (fn walk [arb]

            (recur (conj values (first items)) (next items))
            (recur (conj values (hiccup->arb (first items))) (next items))))))))

(defn html->arb
  ([html] (html->arb html true))
  ([html as-fragment]

    (hiccup->arb (html->hiccup html)))
    (hiccup->arb (html->hiccup html as-fragment))))

(defn html->tx [html & metadata]
  (let [tx (-> html (html->arb) (arb->tx))]
    (assoc tx :arb/metadata (into (:arb/metadata tx) metadata))))

