Extract property fetching into function
1 file changed, 10 insertions(+), 5 deletions(-)
jump to
M src/microformats/parser.clj → src/microformats/parser.clj
@@ -171,15 +171,20 @@ "Parse implied properties of a HTML element" [element] {:name (imply-name element)}) +(defn get-mf-properties + "Parse children of a microformat, returning a map of properties" + [element] + (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 parse-h "Parse h-* classes within a HTML element." [element] (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-")])))))) + :properties (get-mf-properties element))) (defn select-h "Select h-* elements within a HTML document."