rusteerio 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +73 -0
- package/Cargo.lock +1051 -0
- package/Cargo.toml +36 -0
- package/LICENSE +21 -0
- package/README.md +252 -2
- package/RELEASING.md +138 -0
- package/THIRD_PARTY_NOTICES.md +7443 -0
- package/build.rs +3 -0
- package/dist/chunk-DKULX6VO.mjs +3185 -0
- package/dist/chunk-DKULX6VO.mjs.map +1 -0
- package/dist/chunk-OHPGEY3E.mjs +32 -0
- package/dist/chunk-OHPGEY3E.mjs.map +1 -0
- package/dist/index.cjs +3230 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.mjs +38 -0
- package/dist/index.mjs.map +1 -0
- package/dist/slim.cjs +2441 -0
- package/dist/slim.cjs.map +1 -0
- package/dist/slim.d.mts +11 -0
- package/dist/slim.d.ts +11 -0
- package/dist/slim.mjs +19 -0
- package/dist/slim.mjs.map +1 -0
- package/dist/types-BP6TpxE5.d.mts +532 -0
- package/dist/types-BP6TpxE5.d.ts +532 -0
- package/dist/utils.cjs +61 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.mts +13 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.mjs +17 -0
- package/dist/utils.mjs.map +1 -0
- package/native/src/arena.rs +1781 -0
- package/native/src/attributes.rs +923 -0
- package/native/src/codec.rs +172 -0
- package/native/src/diagnostics.rs +1249 -0
- package/native/src/extraction.rs +226 -0
- package/native/src/gc.rs +166 -0
- package/native/src/hook_sink.rs +727 -0
- package/native/src/hook_stream.rs +513 -0
- package/native/src/lib.rs +2095 -0
- package/native/src/location.rs +392 -0
- package/native/src/runtime.rs +189 -0
- package/native/src/selector.rs +1287 -0
- package/native/src/sink.rs +261 -0
- package/native/src/stream.rs +334 -0
- package/native/src/tokenizer.rs +355 -0
- package/native/src/tracker.rs +232 -0
- package/native/vendor/README.md +25 -0
- package/native/vendor/html5ever-0.35.0/.cargo_vcs_info.json +6 -0
- package/native/vendor/html5ever-0.35.0/Cargo.lock +828 -0
- package/native/vendor/html5ever-0.35.0/Cargo.toml +85 -0
- package/native/vendor/html5ever-0.35.0/LICENSE-APACHE +201 -0
- package/native/vendor/html5ever-0.35.0/LICENSE-MIT +25 -0
- package/native/vendor/html5ever-0.35.0/README.md +60 -0
- package/native/vendor/html5ever-0.35.0/benches/html5ever.rs +86 -0
- package/native/vendor/html5ever-0.35.0/data/bench/lipsum-zh.html +19 -0
- package/native/vendor/html5ever-0.35.0/data/bench/lipsum.html +40 -0
- package/native/vendor/html5ever-0.35.0/data/bench/medium-fragment.html +24 -0
- package/native/vendor/html5ever-0.35.0/data/bench/small-fragment.html +7 -0
- package/native/vendor/html5ever-0.35.0/data/bench/strong.html +1 -0
- package/native/vendor/html5ever-0.35.0/data/bench/tiny-fragment.html +1 -0
- package/native/vendor/html5ever-0.35.0/examples/arena.rs +356 -0
- package/native/vendor/html5ever-0.35.0/examples/capi/tokenize.c +74 -0
- package/native/vendor/html5ever-0.35.0/examples/noop-tokenize.rs +47 -0
- package/native/vendor/html5ever-0.35.0/examples/noop-tree-builder.rs +132 -0
- package/native/vendor/html5ever-0.35.0/examples/print-tree-actions.rs +185 -0
- package/native/vendor/html5ever-0.35.0/examples/tokenize.rs +111 -0
- package/native/vendor/html5ever-0.35.0/src/driver.rs +148 -0
- package/native/vendor/html5ever-0.35.0/src/lib.rs +30 -0
- package/native/vendor/html5ever-0.35.0/src/macros.rs +34 -0
- package/native/vendor/html5ever-0.35.0/src/serialize/mod.rs +255 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/char_ref/mod.rs +451 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/interface.rs +99 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/mod.rs +2305 -0
- package/native/vendor/html5ever-0.35.0/src/tokenizer/states.rs +97 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/data.rs +170 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/mod.rs +1848 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/rules.rs +1494 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/tag_sets.rs +114 -0
- package/native/vendor/html5ever-0.35.0/src/tree_builder/types.rs +91 -0
- package/native/vendor/html5ever-0.35.0/src/util/str.rs +52 -0
- package/native/vendor/html5gum-0.8.4/Cargo.lock +1006 -0
- package/native/vendor/html5gum-0.8.4/Cargo.toml +109 -0
- package/native/vendor/html5gum-0.8.4/LICENSE +19 -0
- package/native/vendor/html5gum-0.8.4/README.md +110 -0
- package/native/vendor/html5gum-0.8.4/benches/files/0050.html +2131 -0
- package/native/vendor/html5gum-0.8.4/benches/files/6D30.html +1004 -0
- package/native/vendor/html5gum-0.8.4/benches/files.rs +32 -0
- package/native/vendor/html5gum-0.8.4/benches/patterns.rs +31 -0
- package/native/vendor/html5gum-0.8.4/src/arrayvec.rs +29 -0
- package/native/vendor/html5gum-0.8.4/src/char_validator.rs +134 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/callback.rs +676 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/default.rs +207 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/emitter.rs +344 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/html5ever.rs +306 -0
- package/native/vendor/html5gum-0.8.4/src/emitters/mod.rs +25 -0
- package/native/vendor/html5gum-0.8.4/src/entities.rs +3342 -0
- package/native/vendor/html5gum-0.8.4/src/error.rs +96 -0
- package/native/vendor/html5gum-0.8.4/src/htmlstring.rs +130 -0
- package/native/vendor/html5gum-0.8.4/src/lib.rs +66 -0
- package/native/vendor/html5gum-0.8.4/src/machine.rs +2136 -0
- package/native/vendor/html5gum-0.8.4/src/machine_helper.rs +277 -0
- package/native/vendor/html5gum-0.8.4/src/read_helper.rs +244 -0
- package/native/vendor/html5gum-0.8.4/src/reader.rs +440 -0
- package/native/vendor/html5gum-0.8.4/src/span.rs +98 -0
- package/native/vendor/html5gum-0.8.4/src/state.rs +16 -0
- package/native/vendor/html5gum-0.8.4/src/testutils.rs +71 -0
- package/native/vendor/html5gum-0.8.4/src/tokenizer.rs +189 -0
- package/native/vendor/html5gum-0.8.4/src/utils.rs +88 -0
- package/native/vendor/markup5ever-0.35.0/.cargo_vcs_info.json +6 -0
- package/native/vendor/markup5ever-0.35.0/Cargo.toml +45 -0
- package/native/vendor/markup5ever-0.35.0/LICENSE-APACHE +201 -0
- package/native/vendor/markup5ever-0.35.0/LICENSE-MIT +25 -0
- package/native/vendor/markup5ever-0.35.0/interface/mod.rs +422 -0
- package/native/vendor/markup5ever-0.35.0/interface/tree_builder.rs +280 -0
- package/native/vendor/markup5ever-0.35.0/lib.rs +59 -0
- package/native/vendor/markup5ever-0.35.0/serialize.rs +77 -0
- package/native/vendor/markup5ever-0.35.0/util/buffer_queue.rs +333 -0
- package/native/vendor/markup5ever-0.35.0/util/smallcharset.rs +88 -0
- package/package.json +137 -4
- package/rusteerio.darwin-arm64.node +0 -0
- package/rusteerio.darwin-x64.node +0 -0
- package/rusteerio.linux-arm64-gnu.node +0 -0
- package/rusteerio.linux-arm64-musl.node +0 -0
- package/rusteerio.linux-x64-gnu.node +0 -0
- package/rusteerio.linux-x64-musl.node +0 -0
- package/rusteerio.win32-arm64-msvc.node +0 -0
- package/rusteerio.win32-x64-msvc.node +0 -0
- package/scripts/check-native.mjs +15 -0
- package/scripts/check-release.mjs +235 -0
- package/scripts/fix-declarations.mjs +27 -0
- package/scripts/generate-notices.mjs +176 -0
- package/scripts/notices/README.md +13 -0
- package/scripts/notices/cheerio-MIT.txt +21 -0
- package/scripts/notices/html5ever-AUTHORS.txt +20 -0
- package/scripts/notices/html5ever-COPYRIGHT.txt +8 -0
- package/scripts/notices/html5ever-LICENSE-APACHE.txt +201 -0
- package/scripts/notices/html5ever-LICENSE-MIT.txt +25 -0
- package/scripts/notices/napi-rs-MIT.txt +43 -0
- package/scripts/notices/neon-MIT.txt +19 -0
- package/scripts/notices/runtime-01c266bced4a434da005.txt +3 -0
- package/scripts/notices/runtime-0a54e647fe54104658b5.txt +14 -0
- package/scripts/notices/runtime-0b74dfa0bcee5c420c6b.txt +25 -0
- package/scripts/notices/runtime-0d542e0c8804e39aa7f3.txt +177 -0
- package/scripts/notices/runtime-0f96a83840e146e43c0e.txt +21 -0
- package/scripts/notices/runtime-123a331b5dbf04c30097.txt +25 -0
- package/scripts/notices/runtime-172020dbfd5b53a226df.txt +34 -0
- package/scripts/notices/runtime-209fbbe0ad52d9235e37.txt +26 -0
- package/scripts/notices/runtime-23f18e03dc49df91622f.txt +23 -0
- package/scripts/notices/runtime-268872b9816f90fd8e85.txt +220 -0
- package/scripts/notices/runtime-35242e7a83f69875e6ed.txt +176 -0
- package/scripts/notices/runtime-378f5840b258e2779c39.txt +25 -0
- package/scripts/notices/runtime-4108245a1f2df9d4e94d.txt +25 -0
- package/scripts/notices/runtime-4455bf75a91154108304.txt +21 -0
- package/scripts/notices/runtime-553fffcd9b1cb158bc3e.txt +13 -0
- package/scripts/notices/runtime-62c7a1e35f56406896d7.txt +176 -0
- package/scripts/notices/runtime-6485b8ed310d3f0340bf.txt +25 -0
- package/scripts/notices/runtime-69fef7b0f322a6555415.txt +201 -0
- package/scripts/notices/runtime-6df43f6f4b5d4587f3d8.txt +187 -0
- package/scripts/notices/runtime-799e9ca9d179295ef372.txt +24 -0
- package/scripts/notices/runtime-7b63ecd5f1902af1b637.txt +25 -0
- package/scripts/notices/runtime-7bc7d5de2a0b793d4e1a.txt +21 -0
- package/scripts/notices/runtime-7e12e5df4bae12cb2158.txt +24 -0
- package/scripts/notices/runtime-861399f8c21c042b1105.txt +12 -0
- package/scripts/notices/runtime-8ada45cd9f843acf64e4.txt +201 -0
- package/scripts/notices/runtime-90eb64f0279b0d9432ac.txt +12 -0
- package/scripts/notices/runtime-a60eea817514531668d7.txt +201 -0
- package/scripts/notices/runtime-a7c936ff1ed8fa340172.txt +25 -0
- package/scripts/notices/runtime-ab6eec6caf0fa5775e41.txt +275 -0
- package/scripts/notices/runtime-b1181a40b2a7b25cf66f.txt +19 -0
- package/scripts/notices/runtime-b71bd43a069ca0641a9e.txt +25 -0
- package/scripts/notices/runtime-c16f8dcf1a368b83be78.txt +201 -0
- package/scripts/notices/runtime-c2cfccb812fe482101a8.txt +21 -0
- package/scripts/notices/runtime-e99d88d232bf57d70f0f.txt +25 -0
- package/scripts/notices/runtime-f32fb3b417a194167cfa.txt +9 -0
- package/scripts/notices/runtime-f5062c9a188d81dfe66b.txt +39 -0
- package/scripts/notices/runtime-f9070a832833fa7488fd.txt +4 -0
- package/scripts/notices/runtime-fab3dd6bdab226f1c086.txt +373 -0
- package/scripts/notices/runtime-fba3318d0c600380177e.txt +62 -0
- package/scripts/notices/runtime-ff8f68cb076caf8cefe7.txt +25 -0
- package/scripts/notices/runtime-ff92bed461f50338dd70.txt +74 -0
- package/scripts/notices/runtime.json +1632 -0
- package/scripts/notices/sources.json +555 -0
- package/scripts/notices/xray-MIT.txt +21 -0
- package/src/attributes.ts +271 -0
- package/src/codec.ts +74 -0
- package/src/dom.ts +87 -0
- package/src/extract-plan.ts +97 -0
- package/src/extract.ts +130 -0
- package/src/hooks.ts +220 -0
- package/src/index.ts +223 -0
- package/src/io.ts +491 -0
- package/src/native.ts +135 -0
- package/src/nodes.ts +290 -0
- package/src/parse.ts +53 -0
- package/src/parser-types.ts +157 -0
- package/src/router.ts +327 -0
- package/src/selection.ts +566 -0
- package/src/slim.ts +12 -0
- package/src/transport.ts +104 -0
- package/src/types.ts +186 -0
- package/src/utils.ts +29 -0
- package/src/workers.ts +21 -0
- package/tsconfig.json +15 -0
- package/tsup.config.ts +16 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2014-2017 The html5ever Project Developers. See the
|
|
2
|
+
// COPYRIGHT file at the top-level directory of this distribution.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
6
|
+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
7
|
+
// option. This file may not be copied, modified, or distributed
|
|
8
|
+
// except according to those terms.
|
|
9
|
+
|
|
10
|
+
//! Various sets of HTML tag names, and macros for declaring them.
|
|
11
|
+
|
|
12
|
+
use crate::ExpandedName;
|
|
13
|
+
use markup5ever::{expanded_name, local_name, ns};
|
|
14
|
+
|
|
15
|
+
macro_rules! declare_tag_set_impl ( ($param:ident, $b:ident, $supr:ident, $($tag:tt)+) => (
|
|
16
|
+
match $param {
|
|
17
|
+
$( expanded_name!(html $tag) => $b, )+
|
|
18
|
+
p => $supr(p),
|
|
19
|
+
}
|
|
20
|
+
));
|
|
21
|
+
|
|
22
|
+
macro_rules! declare_tag_set_body (
|
|
23
|
+
($param:ident = [$supr:ident] - $($tag:tt)+)
|
|
24
|
+
=> ( declare_tag_set_impl!($param, false, $supr, $($tag)+) );
|
|
25
|
+
|
|
26
|
+
($param:ident = [$supr:ident] + $($tag:tt)+)
|
|
27
|
+
=> ( declare_tag_set_impl!($param, true, $supr, $($tag)+) );
|
|
28
|
+
|
|
29
|
+
($param:ident = $($tag:tt)+)
|
|
30
|
+
=> ( declare_tag_set_impl!($param, true, empty_set, $($tag)+) );
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
macro_rules! declare_tag_set (
|
|
34
|
+
(pub $name:ident = $($toks:tt)+) => (
|
|
35
|
+
pub(crate) fn $name(p: crate::ExpandedName) -> bool {
|
|
36
|
+
declare_tag_set_body!(p = $($toks)+)
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
($name:ident = $($toks:tt)+) => (
|
|
41
|
+
fn $name(p: crate::ExpandedName) -> bool {
|
|
42
|
+
declare_tag_set_body!(p = $($toks)+)
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
#[inline(always)]
|
|
48
|
+
pub(crate) fn empty_set(_: ExpandedName) -> bool {
|
|
49
|
+
false
|
|
50
|
+
}
|
|
51
|
+
#[inline(always)]
|
|
52
|
+
pub(crate) fn full_set(_: ExpandedName) -> bool {
|
|
53
|
+
true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare_tag_set!(pub html_default_scope =
|
|
57
|
+
"applet" "caption" "html" "table" "td" "th" "marquee" "object" "template");
|
|
58
|
+
|
|
59
|
+
#[inline(always)]
|
|
60
|
+
pub(crate) fn default_scope(name: ExpandedName) -> bool {
|
|
61
|
+
html_default_scope(name)
|
|
62
|
+
|| mathml_text_integration_point(name)
|
|
63
|
+
|| svg_html_integration_point(name)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare_tag_set!(pub list_item_scope = [default_scope] + "ol" "ul");
|
|
67
|
+
declare_tag_set!(pub button_scope = [default_scope] + "button");
|
|
68
|
+
declare_tag_set!(pub table_scope = "html" "table" "template");
|
|
69
|
+
declare_tag_set!(pub select_scope = [full_set] - "optgroup" "option");
|
|
70
|
+
|
|
71
|
+
declare_tag_set!(pub table_body_context = "tbody" "tfoot" "thead" "template" "html");
|
|
72
|
+
declare_tag_set!(pub table_row_context = "tr" "template" "html");
|
|
73
|
+
declare_tag_set!(pub td_th = "td" "th");
|
|
74
|
+
|
|
75
|
+
declare_tag_set!(pub cursory_implied_end =
|
|
76
|
+
"dd" "dt" "li" "option" "optgroup" "p" "rb" "rp" "rt" "rtc");
|
|
77
|
+
|
|
78
|
+
declare_tag_set!(pub thorough_implied_end = [cursory_implied_end]
|
|
79
|
+
+ "caption" "colgroup" "tbody" "td" "tfoot" "th" "thead" "tr");
|
|
80
|
+
|
|
81
|
+
declare_tag_set!(pub heading_tag = "h1" "h2" "h3" "h4" "h5" "h6");
|
|
82
|
+
|
|
83
|
+
declare_tag_set!(pub special_tag =
|
|
84
|
+
"address" "applet" "area" "article" "aside" "base" "basefont" "bgsound" "blockquote" "body"
|
|
85
|
+
"br" "button" "caption" "center" "col" "colgroup" "dd" "details" "dir" "div" "dl" "dt" "embed"
|
|
86
|
+
"fieldset" "figcaption" "figure" "footer" "form" "frame" "frameset" "h1" "h2" "h3" "h4" "h5"
|
|
87
|
+
"h6" "head" "header" "hgroup" "hr" "html" "iframe" "img" "input" "isindex" "li" "link"
|
|
88
|
+
"listing" "main" "marquee" "menu" "meta" "nav" "noembed" "noframes" "noscript"
|
|
89
|
+
"object" "ol" "p" "param" "plaintext" "pre" "script" "section" "select" "source" "style"
|
|
90
|
+
"summary" "table" "tbody" "td" "template" "textarea" "tfoot" "th" "thead" "title" "tr" "track"
|
|
91
|
+
"ul" "wbr" "xmp");
|
|
92
|
+
//§ END
|
|
93
|
+
|
|
94
|
+
pub(crate) fn mathml_text_integration_point(p: ExpandedName) -> bool {
|
|
95
|
+
matches!(
|
|
96
|
+
p,
|
|
97
|
+
expanded_name!(mathml "mi")
|
|
98
|
+
| expanded_name!(mathml "mo")
|
|
99
|
+
| expanded_name!(mathml "mn")
|
|
100
|
+
| expanded_name!(mathml "ms")
|
|
101
|
+
| expanded_name!(mathml "mtext")
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/// https://html.spec.whatwg.org/multipage/#html-integration-point
|
|
106
|
+
pub(crate) fn svg_html_integration_point(p: ExpandedName) -> bool {
|
|
107
|
+
// annotation-xml are handle in another place
|
|
108
|
+
matches!(
|
|
109
|
+
p,
|
|
110
|
+
expanded_name!(svg "foreignObject")
|
|
111
|
+
| expanded_name!(svg "desc")
|
|
112
|
+
| expanded_name!(svg "title")
|
|
113
|
+
)
|
|
114
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright 2014-2017 The html5ever Project Developers. See the
|
|
2
|
+
// COPYRIGHT file at the top-level directory of this distribution.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
6
|
+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
7
|
+
// option. This file may not be copied, modified, or distributed
|
|
8
|
+
// except according to those terms.
|
|
9
|
+
|
|
10
|
+
//! Types used within the tree builder code. Not exported to users.
|
|
11
|
+
|
|
12
|
+
use crate::tokenizer::states::RawKind;
|
|
13
|
+
use crate::tokenizer::Tag;
|
|
14
|
+
|
|
15
|
+
use crate::tendril::StrTendril;
|
|
16
|
+
|
|
17
|
+
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
|
18
|
+
pub(crate) enum InsertionMode {
|
|
19
|
+
Initial,
|
|
20
|
+
BeforeHtml,
|
|
21
|
+
BeforeHead,
|
|
22
|
+
InHead,
|
|
23
|
+
InHeadNoscript,
|
|
24
|
+
AfterHead,
|
|
25
|
+
InBody,
|
|
26
|
+
Text,
|
|
27
|
+
InTable,
|
|
28
|
+
InTableText,
|
|
29
|
+
InCaption,
|
|
30
|
+
InColumnGroup,
|
|
31
|
+
InTableBody,
|
|
32
|
+
InRow,
|
|
33
|
+
InCell,
|
|
34
|
+
InSelect,
|
|
35
|
+
InSelectInTable,
|
|
36
|
+
InTemplate,
|
|
37
|
+
AfterBody,
|
|
38
|
+
InFrameset,
|
|
39
|
+
AfterFrameset,
|
|
40
|
+
AfterAfterBody,
|
|
41
|
+
AfterAfterFrameset,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
|
|
45
|
+
pub(crate) enum SplitStatus {
|
|
46
|
+
NotSplit,
|
|
47
|
+
Whitespace,
|
|
48
|
+
NotWhitespace,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// A subset/refinement of `tokenizer::Token`. Everything else is handled
|
|
52
|
+
/// specially at the beginning of `process_token`.
|
|
53
|
+
#[derive(PartialEq, Eq, Clone, Debug)]
|
|
54
|
+
#[allow(clippy::enum_variant_names)]
|
|
55
|
+
pub(crate) enum Token {
|
|
56
|
+
Tag(Tag),
|
|
57
|
+
Comment(StrTendril),
|
|
58
|
+
Characters(SplitStatus, StrTendril),
|
|
59
|
+
NullCharacter,
|
|
60
|
+
Eof,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
pub(crate) enum ProcessResult<Handle> {
|
|
64
|
+
Done,
|
|
65
|
+
DoneAckSelfClosing,
|
|
66
|
+
SplitWhitespace(StrTendril),
|
|
67
|
+
Reprocess(InsertionMode, Token),
|
|
68
|
+
#[allow(dead_code)] // FIXME
|
|
69
|
+
ReprocessForeign(Token),
|
|
70
|
+
Script(Handle),
|
|
71
|
+
ToPlaintext,
|
|
72
|
+
ToRawData(RawKind),
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
pub(crate) enum FormatEntry<Handle> {
|
|
76
|
+
Element(Handle, Tag),
|
|
77
|
+
Marker,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
pub(crate) enum InsertionPoint<Handle> {
|
|
81
|
+
/// Insert as last child in this parent.
|
|
82
|
+
LastChild(Handle),
|
|
83
|
+
#[allow(dead_code)] // FIXME
|
|
84
|
+
/// Insert before this following sibling.
|
|
85
|
+
BeforeSibling(Handle),
|
|
86
|
+
/// Insertion point is decided based on existence of element's parent node.
|
|
87
|
+
TableFosterParenting {
|
|
88
|
+
element: Handle,
|
|
89
|
+
prev_element: Handle,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Copyright 2014-2017 The html5ever Project Developers. See the
|
|
2
|
+
// COPYRIGHT file at the top-level directory of this distribution.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
6
|
+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
7
|
+
// option. This file may not be copied, modified, or distributed
|
|
8
|
+
// except according to those terms.
|
|
9
|
+
|
|
10
|
+
use std::fmt;
|
|
11
|
+
|
|
12
|
+
pub(crate) fn to_escaped_string<T: fmt::Debug>(x: &T) -> String {
|
|
13
|
+
// FIXME: don't allocate twice
|
|
14
|
+
let string = format!("{x:?}");
|
|
15
|
+
string.chars().flat_map(|c| c.escape_default()).collect()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// If `c` is an ASCII letter, return the corresponding lowercase
|
|
19
|
+
/// letter, otherwise None.
|
|
20
|
+
pub(crate) fn lower_ascii_letter(c: char) -> Option<char> {
|
|
21
|
+
match c {
|
|
22
|
+
'a'..='z' => Some(c),
|
|
23
|
+
'A'..='Z' => Some((c as u8 - b'A' + b'a') as char),
|
|
24
|
+
_ => None,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#[cfg(test)]
|
|
29
|
+
#[allow(non_snake_case)]
|
|
30
|
+
mod test {
|
|
31
|
+
use super::lower_ascii_letter;
|
|
32
|
+
|
|
33
|
+
#[test]
|
|
34
|
+
fn lower_letter_a_is_a() {
|
|
35
|
+
assert_eq!(lower_ascii_letter('a'), Some('a'));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#[test]
|
|
39
|
+
fn lower_letter_A_is_a() {
|
|
40
|
+
assert_eq!(lower_ascii_letter('A'), Some('a'));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#[test]
|
|
44
|
+
fn lower_letter_symbol_is_None() {
|
|
45
|
+
assert_eq!(lower_ascii_letter('!'), None);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
#[test]
|
|
49
|
+
fn lower_letter_nonascii_is_None() {
|
|
50
|
+
assert_eq!(lower_ascii_letter('\u{a66e}'), None);
|
|
51
|
+
}
|
|
52
|
+
}
|