Split h-* selection and parsing
1 file changed, 6 insertions(+), 6 deletions(-)
jump to
M src/microformats/parser.clj → src/microformats/parser.clj
@@ -144,8 +144,8 @@ ((classes-to-props "e-")) (r/map #(hash-map % (get-e-value element))) (into {}))) -(defn parse-children - "Parse element children for microformats" +(defn parse-h + "Parse h-* classes within a HTML element." [element] (let [el (first (html/select element [(html/union [(html/attr-starts :class "p-") (html/attr-starts :class "u-")@@ -153,10 +153,10 @@ (html/attr-starts :class "dt-") (html/attr-starts :class "e-")])]))] (hash-map :properties (apply merge ((juxt parse-p parse-u parse-dt parse-e) el))))) -(defn parse-h - "Parse h-* classes within a HTML document." +(defn select-h + "Select h-* elements within a HTML document." [element] - (mapv parse-children (html/select element [(html/attr-starts :class "h-")]))) + (html/select element [(html/attr-starts :class "h-")])) (defn parse-rel "Parse rel attributes of an HTML link element"@@ -180,4 +180,4 @@ (defn parse "Parse a HTML string with microformats" [html] (let [document (html/html-snippet html)] - {:items (parse-h document) :rels (parse-rels document)})) + {:items (mapv parse-h (select-h document)) :rels (parse-rels document)}))