all repos — archive/microformats @ 4d0a2cd298536eb630b5f07bafff6add8c2356c8

Incomplete Clojure microformats library

Split h-* selection and parsing

Alan Pearce
commit

4d0a2cd298536eb630b5f07bafff6add8c2356c8

parent

8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d

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

jump to
M src/microformats/parser.cljsrc/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)}))