 
 (defn get-in-metadata [k metadata]
   (k (first (filter #(k %) metadata))))
+
+(defn walk-arb-fn [wrap-node process-node]
+  (fn walk [arb]
+    (let [[_ metadata & nodes] arb]
+      (wrap-node
+       metadata
+       (apply vector (for [node nodes]
+                       (if (or (string? node) (nil? node))
+                         (process-node node)
+                         (walk node))))))))
+
+(defn arb->tx [arb]
+  (let [process-node #(hash-map :content/text %)
+        wrap-node #(hash-map
+                    :arb/metadata [{:metadata/html-tag (:original-tag %1)}]
+                    :arb/value %2)
+        convert (walk-arb-fn wrap-node process-node)]
+    (convert arb)))
+
+(defn arb->hiccup [arb]
+  (let [proccess-node #(identity %)
+        wrap-node #(vec (concat [(:original-tag %1) {}] %2))
+        convert (walk-arb-fn wrap-node proccess-node)]
+    (convert arb)))
 
 (defn html->hiccup
   ([html] (as-hiccup (parse html)))

                         (:content/text (first items)) ;; If it's not an arb it must be a :content/text
                         (tx->arb (first items)))) (next items)))))))

(defn arb->hiccup [arb]
  (let [[arb-tag metadata & value] arb]
    (if (and (string? (first value)) (= 1 (count value)))
      [(:original-tag metadata) {} (first value)]
      (loop [hiccups [], items value]
        (if (= 0 (count items))
          (into [(:original-tag metadata) {}] hiccups)
          (if (string? (first items))
            (recur (conj hiccups (first items)) (next items))
            (recur
              (conj hiccups (arb->hiccup (first items)))
              (next items))))))))

(defn tx->html [tx]
  (-> tx (tx->arb) (arb->hiccup) (html)))

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

(defn tx->arb [tx]
  (let [{metadata :arb/metadata value :arb/value} tx]
    (if (and (= 1 (count value)) (not (nil? (:content/text (first value)))))
