Parse child implied URLs
2 files changed, 6 insertions(+), 1 deletion(-)
M src/microformats/parser.clj → src/microformats/parser.clj
@@ -192,7 +192,8 @@ (defn- parse-implied-url [element] (case (:tag element) :a (-> element :attrs :href) - nil)) + (if-let [% (first (html/select element [html/root :> [:a (html/attr? :href) html/only-of-type (html/but-node (html/attr-contains :class "h-"))]]))] + (-> % :attrs :href)))) (defn- parse-implied-photo [element]
M test/microformats/parser_expectations.clj → test/microformats/parser_expectations.clj
@@ -169,6 +169,10 @@ (expect {:items [{:type ["h-card"] :properties {:name '("Example User") :photo '("http://example.com/me.png")}}] :rels {}} (parse "<div class=\"h-card\"><div><img alt=\"Example User\" src=\"http://example.com/me.png\"></div></div>")) +(expect {:items [{:type ["h-card"] :properties {:name '("Example User") :url '("http://example.com")}}] :rels {}} + (parse "<div class=\"h-card\"><a href=\"http://example.com\">Example User</a></div>")) + + (expect {:items [{:type ["h-adr"], :properties {:street-address '("665 3rd St."),