about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/microformats/parser.clj22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 75f7de9..f89ed8f 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -57,6 +57,19 @@
       (first :content el)
       ""))
 
+(defn get-dt-property
+  "Get the dt-x property value of an element"
+  [el]
+  (or (case (:tag el)
+        :time (-> el :attrs :datetime)
+        :ins  (-> el :attrs :datetime)
+        :del  (-> el :attrs :datetime)
+        :abbr (-> el :attrs :title)
+        :data (-> el :attrs :value)
+        :input (-> el :attrs :value))
+      (first (:content el))
+      ""))
+
 (defn parse-p
   "Parse p-* classes within HTML element."
   [element]
@@ -69,11 +82,18 @@
   (let [prop (get-u-property element)]
     (into {} (r/map #(hash-map % prop) ((classes-to-props "u-") (element-to-classes element))))))
 
+(defn parse-dt
+  "Parse dt-* classes within HTML element"
+  [element]
+  (let [prop (get-dt-property element)]
+    (into {} (r/map #(hash-map % prop) ((classes-to-props "dt-") (element-to-classes element))))))
+
 (defn parse-children
   "Parse element children for microformats"
   [element]
   (let [el (first (html/select element [(html/union [(html/attr-starts :class "p-")
-                                                     (html/attr-starts :class "u-")])]))]
+                                                     (html/attr-starts :class "u-")
+                                                     (html/attr-starts :class "dt-")])]))]
     (hash-map :properties (merge (parse-p el) (parse-u el)))))
 
 (defn parse-h