blob: d8b72252dadb97bb02b765e741da265ef5e41344 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
(ns microformats.parser-expectations
(:require [expectations :refer :all]
[microformats.parser :refer :all]
[net.cgrand.enlive-html :refer [html-snippet]]))
(expect [:location]
(into [] ((classes-to-props "p-") ["someclass" "p-location" "someotherclass"])))
(expect [:location :name]
(into [] ((classes-to-props "p-") ["someclass" "p-location" "someotherclass" "p-name"])))
(expect "Foo <strong>bar</strong>"
(apply str (#'microformats.parser/node-to-html '("Foo " {:tag :strong, :attrs nil, :content ("bar")}))))
(expect {:name "Example User"}
(parse-p (first (html-snippet "<p class=\"p-name\">Example User</p>"))))
(expect {:nickname "exuser"}
(parse-p (first (html-snippet "<p class=\"p-nickname\">exuser</p>"))))
(expect {:name "Example User"}
(parse-p (first (html-snippet "<img class=\"p-name\" alt=\"Example User\">"))))
(expect {:name "Example User"}
(parse-p (first (html-snippet "<abbr class=\"p-name\" title=\"Example User\">@example</abbr>"))))
(expect {:name "@example"}
(parse-p (first (html-snippet "<abbr class=\"p-name\">@example</abbr>"))))
(expect {:name "Example User"}
(parse-p (first (html-snippet "<data class=\"p-name\" value=\"Example User\"></data>"))))
(expect {:name "Example User"}
(parse-p (first (html-snippet "<data class=\"p-name\">Example User</data>"))))
(expect {:name ""}
(parse-p (first (html-snippet "<br class=\"p-name\"/>"))))
(expect {:name ""}
(parse-p (first (html-snippet "<hr class=\"p-name\"/>"))))
(expect {:url "http://example.com"}
(parse-u (first (html-snippet "<a class=\"u-url\" href=\"http://example.com\">Awesome example website</a>"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<img class=\"u-photo\" src=\"http://example.com/someimage.png\">"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<area class=\"u-photo\" href=\"http://example.com/someimage.png\"></area>"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<object class=\"u-photo\" data=\"http://example.com/someimage.png\"></object>"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<abbr class=\"u-photo\" title=\"http://example.com/someimage.png\"></abbr>"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<abbr class=\"u-photo\">http://example.com/someimage.png</abbr>"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<data class=\"u-photo\" value=\"http://example.com/someimage.png\"></data>"))))
(expect {:photo "http://example.com/someimage.png"}
(parse-u (first (html-snippet "<data class=\"u-photo\">http://example.com/someimage.png</data>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<time class=\"dt-start\" datetime=\"2012-08-05T14:50\"></time>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<time class=\"dt-start\">2012-08-05T14:50</time>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<ins class=\"dt-start\" datetime=\"2012-08-05T14:50\"></ins>"))))
(expect {:end "2012-08-05T18:00"}
(parse-dt (first (html-snippet "<del class=\"dt-end\" datetime=\"2012-08-05T18:00\"></del>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<abbr class=\"dt-start\" title=\"2012-08-05T14:50\"></abbr>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<abbr class=\"dt-start\">2012-08-05T14:50</abbr>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<data class=\"dt-start\" value=\"2012-08-05T14:50\"></data>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<data class=\"dt-start\">2012-08-05T14:50</data>"))))
(expect {:start "2012-08-05T14:50"}
(parse-dt (first (html-snippet "<input class=\"dt-start\" value=\"2012-08-05T14:50\">"))))
(expect {:content {:html "Here is a load of <strong>embedded markup</strong>" :value "Here is a load of embedded markup"}}
(parse-e (first (html-snippet "<div class=\"e-content\">Here is a load of <strong>embedded markup</strong></div>"))))
(expect {:author ["http://example.com/a"]}
(parse-rels (html-snippet "<a rel=\"author\" href=\"http://example.com/a\">author a</a>")))
(expect {:author ["http://example.com/a" "http://example.com/b"]}
(parse-rels (html-snippet "<a rel=\"author\" href=\"http://example.com/a\">author a</a>
<a rel=\"author\" href=\"http://example.com/b\">author b</a>")))
(expect {:items [] :rels {}}
(parse ""))
|