about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2014-09-21 20:55:31 +0100
committerAlan Pearce2014-09-21 20:55:31 +0100
commitd5b6c2d56e84a93232c2d3c87d93b70102006bee (patch)
tree7aa6aa8968defe771a651c56ccae8f44a6ce152c /src
parent6d5093970156cc85794c9a5f503f93c9989d461b (diff)
downloadmicroformats-d5b6c2d56e84a93232c2d3c87d93b70102006bee.tar.lz
microformats-d5b6c2d56e84a93232c2d3c87d93b70102006bee.tar.zst
microformats-d5b6c2d56e84a93232c2d3c87d93b70102006bee.zip
Add initial implied property parsing
Diffstat (limited to 'src')
-rw-r--r--src/microformats/parser.clj13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 38bca21..b3af5e3 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -152,6 +152,16 @@
        (r/filter (mf-names-from-class "h-"))
        (into [])))
 
+(defn- imply-name
+  "Imply the name of an entity from the element"
+  [element]
+  (or (first (:content element))))
+
+(defn parse-implied
+  "Parse implied properties of a HTML element"
+  [element]
+  {:name (imply-name element)})
+
 (defn parse-h
   "Parse h-* classes within a HTML element."
   [element]
@@ -160,7 +170,8 @@
                                                      (html/attr-starts :class "dt-")
                                                      (html/attr-starts :class "e-")])]))]
     (hash-map :type (get-mf-names element)
-              :properties (apply merge ((juxt parse-p parse-u parse-dt parse-e) el)))))
+              :properties (merge (parse-implied element)
+                                 (apply merge ((juxt parse-p parse-u parse-dt parse-e) el))))))
 
 (defn select-h
   "Select h-* elements within a HTML document."