all repos — archive/microformats @ f45945cad76b864fa4a84277f6581ffef31e225e

Incomplete Clojure microformats library

Refactor property element selection and parsing

Alan Pearce
commit

f45945cad76b864fa4a84277f6581ffef31e225e

parent

58552fe2b3d5953b8bcc6a97fb87dc44bda4f180

1 file changed, 6 insertions(+), 7 deletions(-)

jump to
M src/microformats/parser.cljsrc/microformats/parser.clj
@@ -174,13 +174,12 @@
(defn parse-h "Parse h-* classes within a HTML element." [element] - (let [el (html/select element [(html/union [(html/attr-starts :class "p-") - (html/attr-starts :class "u-") - (html/attr-starts :class "dt-") - (html/attr-starts :class "e-")])])] - (hash-map :type (get-mf-names element) - :properties (merge (parse-implied element) - (apply merge (map #(apply merge %) (map (juxt parse-p parse-u parse-dt parse-e) el))))))) + (hash-map :type (get-mf-names element) + :properties (merge (parse-implied element) + (apply merge (map parse-p (html/select element [(html/attr-starts :class "p-")]))) + (apply merge (map parse-u (html/select element [(html/attr-starts :class "u-")]))) + (apply merge (map parse-dt (html/select element [(html/attr-starts :class "dt-")]))) + (apply merge (map parse-e (html/select element [(html/attr-starts :class "e-")])))))) (defn select-h "Select h-* elements within a HTML document."