diff options
author | Alan Pearce | 2014-09-10 19:03:56 +0100 |
---|---|---|
committer | Alan Pearce | 2014-09-10 19:03:56 +0100 |
commit | cba956458645f10a83d9f44f40b30e422de8ec63 (patch) | |
tree | 882b7f527557f211edfab4246bd6fe2a46f36c52 /src | |
parent | fc18e6363dcb0befca0088a66284b05979ee3036 (diff) | |
download | microformats-cba956458645f10a83d9f44f40b30e422de8ec63.tar.lz microformats-cba956458645f10a83d9f44f40b30e422de8ec63.tar.zst microformats-cba956458645f10a83d9f44f40b30e422de8ec63.zip |
Create test & implementation for p-name parsing
Diffstat (limited to 'src')
-rw-r--r-- | src/microformats/parser.clj | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index c741549..c44803b 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -1,6 +1,20 @@ -(ns microformats.parser) +(ns microformats.parser + (:require [net.cgrand.enlive-html :as html])) + +;;; Turn string into stream + +(defn parse-p + "Parse p-* classes within HTML element." + [element] + (hash-map :properties (hash-map :name (first (:content (first (html/select element [:.p-name]))))))) + +(defn parse-h + "Parse h-* classes within a HTML document." + [html] + (mapv parse-p (html/select html [:.h-card]))) (defn parse "Parse a HTML string with microformats" [html] - {:items [] :rels {}}) + (let [document (html/html-snippet html)] + {:items (parse-h document) :rels {}})) |