about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/microformats/parser.clj13
-rw-r--r--test/microformats/parser_expectations.clj3
2 files changed, 14 insertions, 2 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 4f9f9e9..b28fce7 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -164,7 +164,9 @@
 (defn- imply-name
   "Imply the name of an entity from the element"
   [element]
-  (node-to-text (:content element)))
+  (case (:tag element)
+    :img (-> element :attrs :alt)
+    (node-to-text (:content element))))
 
 (defn- imply-url
   [element]
@@ -172,12 +174,19 @@
     :a (-> element :attrs :href)
     nil))
 
+(defn- imply-photo
+  [element]
+  (case (:tag element)
+    :img (-> element :attrs :src)
+    nil))
+
 (defn parse-implied
   "Parse implied properties of a HTML element"
   [element]
   (into {} (filter #(first (second %))
                    {:name (list (imply-name element))
-                    :url (list (imply-url element))})))
+                    :url (list (imply-url element))
+                    :photo (list (imply-photo element))})))
 
 (defn get-mf-properties
   "Parse children of a microformat, returning a map of properties"
diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj
index bf39778..c903165 100644
--- a/test/microformats/parser_expectations.clj
+++ b/test/microformats/parser_expectations.clj
@@ -133,6 +133,9 @@
 (expect {:items [{:type ["h-card"] :properties {:name '("Example User") :url '("http://example.com")}}] :rels {}}
         (parse "<a class=\"h-card\" href=\"http://example.com\">Example User</a>"))
 
+(expect {:items [{:type ["h-card"] :properties {:name '("Example User")
+                                                :photo '("http://example.com/me.png")}}] :rels {}}
+        (parse "<img class=\"h-card\" alt=\"Example User\" src=\"http://example.com/me.png\"></img>"))
 (expect
  {:items [{:type ["h-adr"],
            :properties {:street-address '("665 3rd St."),