1 ! Copyright (C) 2010 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: html.parser html.parser.analyzer kernel math sequences tools.test ;
6 [ 1 { 3 5 7 9 11 } [ odd? ] find-nth ] unit-test
9 [ 3 { 3 5 7 9 11 } [ odd? ] find-nth ] unit-test
12 [ 3 1 { 3 5 7 9 11 } [ odd? ] find-nth-from ] unit-test
15 [ 1 { 3 5 7 9 11 } [ odd? ] find-last-nth ] unit-test
18 [ 3 { 3 5 7 9 11 } [ odd? ] find-last-nth ] unit-test
21 [ 1 2 { 3 5 7 9 11 } [ odd? ] find-last-nth-from ] unit-test
24 [ 0 { 3 5 7 9 11 } [ odd? ] find-nth ]
25 [ undefined-find-nth? ] must-fail-with
27 [ 0 { 3 5 7 9 11 } [ odd? ] find-last-nth ]
28 [ undefined-find-nth? ] must-fail-with
31 T{ tag f text f "foo" f }
34 "<!DOCTYPE html><html><head><title>foo</title></head></html>" parse-html
35 "title" find-between-first
39 T{ tag f "p" H{ } f f }
40 T{ tag f text f "para" f }
41 T{ tag f "p" H{ } f t }
44 "<body><div><p>para</p></div></body>" parse-html "div" find-between-first
48 T{ tag f "div" H{ { "class" "foo" } } f f }
49 T{ tag f "p" H{ } f f }
50 T{ tag f text f "para" f }
51 T{ tag f "p" H{ } f t }
52 T{ tag f "div" H{ } f t }
55 "<body><div class=\"foo\"><p>para</p></div></body>" parse-html
56 "foo" find-by-class-between
60 T{ tag f "div" H{ { "class" "foo" } } f f }
61 T{ tag f "div" H{ } f f }
62 T{ tag f "p" H{ } f f }
63 T{ tag f text f "para" f }
64 T{ tag f "p" H{ } f t }
65 T{ tag f "div" H{ } f t }
66 T{ tag f "div" H{ } f t }
69 "<body><div class=\"foo\"><div><p>para</p></div></div></body>" parse-html
70 "foo" find-by-class-between
74 T{ tag { name "f" } { attributes H{ { "class" "a b c" } } } }
75 { "a" "b" "c" } [ html-class? ] with all?
82 { attributes H{ { "class" "foo and more" } } }
84 T{ tag { name "div" } { attributes H{ } } { closing? t } }
86 } [ "<div class=\"foo and more\"></div>" parse-html
87 "foo" find-by-class-between
92 T{ tag { name "div" } { attributes H{ { "class" "foo bar" } } } }
94 "<div class=\"foo bar\"></div>" parse-html "bar" find-by-class