Есть ли анализатор html для икоты структур?

Я ищу функцию, которая обращает икоту clojure

так, что

   <html></html>

превращается в

[:html]

и т. д.


Следуя ответу @kotarak, теперь это работает для меня :

(use 'net.cgrand.enlive-html)
(import 'java.io.StringReader)

(defn enlive->hiccup
   [el]
   (if-not (string? el)
     (->> (map enlive->hiccup (:content el))
       (concat [(:tag el) (:attrs el)])
       (keep identity)
       vec)
     el))

(defn html->enlive 
  [html]
  (first (html-resource (StringReader. html))))

(defn html->hiccup [html]
  (-> html
      html->enlive
      enlive->hiccup))

=> (html->hiccup "<html><body id='foo'>hello</body></html>")
[:html [:body {:id "foo"} "hello"]]
5
задан zcaudate 19 June 2012 в 11:23
поделиться