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
use html_filter::*;
#[test]
fn manual() {
let html = r##"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" >
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Document</title>
</head>
<body>
</body>
</html>
"##;
let tree = Html::parse(html).unwrap();
if let Html::Vec(vec) = &tree {
for elt in vec {
if let Html::Tag { tag, child, .. } = elt {
if tag.as_name() == "html" {
if let Html::Vec(vec) = &**child {
for elt in vec {
if let Html::Tag { tag, child, .. } = elt {
if tag.as_name() == "head" {
if let Html::Vec(vec) = &**child {
for elt in vec {
if let Html::Tag { tag, child, .. } = elt
&& tag.as_name() == "title"
{
if let Html::Text(text) = &**child {
assert!(text == "Document");
return;
} else {
panic!("invalid child of title tag: {child:?}")
}
}
// media
}
panic!("none with name title");
}
panic!("son of head not vec");
}
panic!("first tag is head");
}
// reading some text
}
panic!("none with name head");
}
panic!("son of html not vec");
}
panic!("first tag is html")
}
// reading some text & doctype
}
panic!("none with name html");
} else {
panic!("expected vec");
}
}