|
8 | 8 |
|
9 | 9 | (def html1
|
10 | 10 | "<!DOCTYPE html>
|
11 |
| -<!-- Comment 1 --> |
12 |
| -<html> |
13 |
| -<head></head> |
14 |
| -<body> |
15 |
| -<h1>Heading</h1> |
16 |
| -<p>Paragraph</p> |
17 |
| -<a href=\"http://example.com\">Link</a> |
18 |
| -<div class=\"aclass bclass cool\"> |
19 |
| -<span disabled anotherattr=\"\" thirdthing=\"44\" id=\"attrspan\" |
20 |
| - Capitalized=\"UPPERCASED\"> |
21 |
| -<div class=\"subdiv cool\" id=\"deepestdiv\">Div</div> |
22 |
| -</span> |
23 |
| -<!-- Comment 2 --> |
24 |
| -<span id=\"anid\" class=\"line-feed-ahead |
25 |
| -cool\">Span</span> |
26 |
| -</div> |
27 |
| -</body> |
28 |
| -</html>") |
| 11 | + <!-- Comment 1 --> |
| 12 | + <html> |
| 13 | + <head></head> |
| 14 | + <body> |
| 15 | + <h1>Heading</h1> |
| 16 | + <p>Paragraph</p> |
| 17 | + <a href=\"http://example.com\">Link</a> |
| 18 | + <div class=\"aclass bclass cool\"> |
| 19 | + <span disabled anotherattr=\"\" thirdthing=\"44\" id=\"attrspan\" Capitalized=\"UPPERCASED\"> |
| 20 | + <div class=\"subdiv cool\" id=\"deepestdiv\">Div</div> |
| 21 | + </span> |
| 22 | + <!-- Comment 2 --> |
| 23 | + <span id=\"anid\" class=\"line-feed-ahead cool\">Span</span> |
| 24 | + </div> |
| 25 | + </body> |
| 26 | + </html>") |
29 | 27 |
|
30 | 28 | (def html2
|
31 | 29 | "<!DOCTYPE html>
|
32 |
| -<html> |
33 |
| -<head></head> |
34 |
| -<body> |
35 |
| -<p>Paragraph 1</p> |
36 |
| -<p>Paragraph 2</p> |
37 |
| -<p>Paragraph 3</p> |
38 |
| -<p>Paragraph 4</p> |
39 |
| -<p>Paragraph 5</p> |
40 |
| -<p>Paragraph 6</p> |
41 |
| -<p>Paragraph 7</p> |
42 |
| -<p>Paragraph 8</p> |
43 |
| -</body> |
44 |
| -</html>") |
| 30 | + <html> |
| 31 | + <head></head> |
| 32 | + <body> |
| 33 | + <p>Paragraph 1</p> |
| 34 | + <p>Paragraph 2</p> |
| 35 | + <p>Paragraph 3</p> |
| 36 | + <p>Paragraph 4</p> |
| 37 | + <p>Paragraph 5</p> |
| 38 | + <p>Paragraph 6</p> |
| 39 | + <p>Paragraph 7</p> |
| 40 | + <p>Paragraph 8</p> |
| 41 | + </body> |
| 42 | + </html>") |
45 | 43 |
|
46 | 44 | (deftest select-next-loc-test
|
47 | 45 | (testing "The select-next-loc function."
|
@@ -232,7 +230,15 @@ cool\">Span</span>
|
232 | 230 | (= :h1 (-> selection first :tag)))))
|
233 | 231 | (let [selection (select/select (select/find-in-text #"Div") htree)]
|
234 | 232 | (is (and (= 1 (count selection))
|
235 |
| - (= :div (-> selection first :tag)))))) |
| 233 | + (= :div (-> selection first :tag))))) |
| 234 | + (let [selection-locs (select/select-locs |
| 235 | + (select/child (select/tag :body) |
| 236 | + (select/find-in-text #"Paragraph")) |
| 237 | + htree) |
| 238 | + selection (mapv zip/node selection-locs)] |
| 239 | + (is (and (= 1 (count selection)) |
| 240 | + (= :p (-> selection first :tag)) |
| 241 | + (= :body (-> selection-locs first zip/up zip/node :tag)))))) |
236 | 242 | (let [htree (hickory/as-hickory (hickory/parse html2))]
|
237 | 243 | (let [selection (select/select (select/find-in-text #"Paragraph") htree)]
|
238 | 244 | (is (and (= 8 (count selection))
|
|
0 commit comments