1 ! Copyright (C) 2021 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: io.encodings.utf8 io.files kernel make math modern.html
4 multiline sequences tools.test ;
8 [[ <html>]] string>html
9 ] [ unmatched-open-tags-error? ] must-fail-with
12 [[ <html><body></html>]] string>html
13 ] [ unmatched-open-tags-error? ] must-fail-with
16 [[ <html><body><html/>]] string>html
17 ] [ unmatched-open-tags-error? ] must-fail-with
20 [[ </html>]] string>html
21 ] [ unmatched-closing-tag-error? ] must-fail-with
24 [[ <html></html123>]] string>html
25 ] [ unmatched-closing-tag-error? ] must-fail-with
27 { [[ <html><head>omg</head><body><asdf a b c="d"><a/></asdf></body></html>]] } [
28 [[ <html><head>omg</head><body><asdf a b c="d" > <a/></asdf></body></html>]] string>html html>string
32 [[ <html><head>omg<body></body></html>]] string>html html>string
33 ] [ unmatched-open-tags-error? ] must-fail-with
35 { [[ <!-- omg omg -->]] }
36 [ [[ <!-- omg omg -->]] string>html html>string ] unit-test
38 { "<div><div><a/><b/><c/></div></div>" }
39 [ "<div> <div> <a/> <b/> <c/> </div> </div>" string>html html>string ] unit-test
41 { "<?xml version='1.0'?>" }
42 [ [[ <?xml version='1.0'?> ]] string>html html>string ] unit-test
44 { "<?xml version='1.0'?>" }
45 [ [[ <?xml version='1.0' ?> ]] string>html html>string ] unit-test
57 { payload "-//Apple//DTD PLIST 1.0//EN" }
61 "http://www.apple.com/DTDs/PropertyList-1.0.dtd"
69 [[ <!DOCTYPE plist PUBLIC
70 "-//Apple//DTD PLIST 1.0//EN"
71 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
77 V{ T{ comment { open "<!--" } { payload " comment " } { close "-->" } } }
78 } [ [[ <!-- comment --> ]] string>html ] unit-test
80 ! From wikipedia factor article
81 ! https://en.wikipedia.org/w/index.php?title=Factor_(programming_language)&offset=&limit=500&action=history"
87 { values V{ "html" } }
96 T{ dquote { payload "client-nojs" } }
98 { "lang" T{ dquote { payload "en" } } }
99 { "dir" T{ dquote { payload "ltr" } } }
117 { children V{ "omg" } }
126 { close-tag T{ close-tag { name "head" } } }
152 "{\"_\":\"mw.htmlform.FieldLayout\",\"fieldWidget\":{\"tag\":\"tagfilter\"},\"align\":\"top\",\"helpInline\":true,\"$overlay\":true,\"label\":{\"html\":\"<a href=\\\"\\/wiki\\/Special:Tags\\\" title=\\\"Special:Tags\\\">Tag<\\/a> filter:\"},\"classes\":[\"mw-htmlform-field-HTMLTagFilter\",\"mw-htmlform-autoinfuse\"]}"
168 { close-tag T{ close-tag { name "body" } } }
172 { close-tag T{ close-tag { name "html" } } }
178 <html class="client-nojs" lang="en" dir="ltr">
180 <head> <title>omg</title></head>
183 data-ooui='{"_":"mw.htmlform.FieldLayout","fieldWidget":{"tag":"tagfilter"},"align":"top","helpInline":true,"$overlay":true,"label":{"html":"<a href=\"\/wiki\/Special:Tags\" title=\"Special:Tags\">Tag<\/a> filter:"},"classes":["mw-htmlform-field-HTMLTagFilter","mw-htmlform-autoinfuse"]}'
202 T{ dquote { payload "p-personal-label" } }
207 { payload "vector-menu-heading " }
224 "vector-menu-heading-label"
231 { children V{ "Personal tools" } }
232 { close-tag T{ close-tag { name "span" } } }
236 { close-tag T{ close-tag { name "label" } } }
242 id="p-personal-label"
244 class="vector-menu-heading "
246 <span class="vector-menu-heading-label">Personal tools</span>
251 ! Ensure we can parse <%factor "hi" print %> embedded code
253 "resource:extra/websites/factorcode/index.fhtml" utf8 file-contents
254 string>html [ [ dup embedded-language? [ , ] [ drop ] if ] walk-html ] { } make length 0 >