Refactor property element selection and parsing
1 file changed, 6 insertions(+), 7 deletions(-)
jump to
M src/microformats/parser.clj → src/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."