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,96 @@
|
|
|
1
|
+
macro_rules! impl_error {
|
|
2
|
+
($(
|
|
3
|
+
$string:literal <=> $variant:ident,
|
|
4
|
+
)*) => {
|
|
5
|
+
/// All [parsing errors](https://html.spec.whatwg.org/#parse-errors) this tokenizer can emit.
|
|
6
|
+
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
|
|
7
|
+
pub enum Error {
|
|
8
|
+
$(
|
|
9
|
+
#[doc = "This error corresponds to the `$literal` error found in the WHATWG spec."]
|
|
10
|
+
$variant
|
|
11
|
+
),*
|
|
12
|
+
}
|
|
13
|
+
impl std::str::FromStr for Error {
|
|
14
|
+
type Err = ();
|
|
15
|
+
|
|
16
|
+
/// Parse a `kebap-case` error code as typically written in the WHATWG spec into an
|
|
17
|
+
/// enum variant.
|
|
18
|
+
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
19
|
+
match s {
|
|
20
|
+
$( $string => Ok(Self::$variant), )*
|
|
21
|
+
_ => Err(())
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
impl Error {
|
|
27
|
+
/// Convert an enum variant back into the `kebap-case` error code as typically written
|
|
28
|
+
/// in the WHATWG spec.
|
|
29
|
+
#[must_use]
|
|
30
|
+
pub fn as_str(&self) -> &'static str {
|
|
31
|
+
match *self {
|
|
32
|
+
$( Self::$variant => $string, )*
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
impl std::fmt::Display for Error {
|
|
40
|
+
/// Convert an enum variant back into the `kebap-case` error code as typically written
|
|
41
|
+
/// in the WHATWG spec.
|
|
42
|
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
43
|
+
self.as_str().fmt(f)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
impl_error! {
|
|
48
|
+
"abrupt-closing-of-empty-comment" <=> AbruptClosingOfEmptyComment,
|
|
49
|
+
"abrupt-doctype-public-identifier" <=> AbruptDoctypePublicIdentifier,
|
|
50
|
+
"abrupt-doctype-system-identifier" <=> AbruptDoctypeSystemIdentifier,
|
|
51
|
+
"absence-of-digits-in-numeric-character-reference" <=> AbsenceOfDigitsInNumericCharacterReference,
|
|
52
|
+
"cdata-in-html-content" <=> CdataInHtmlContent,
|
|
53
|
+
"character-reference-outside-unicode-range" <=> CharacterReferenceOutsideUnicodeRange,
|
|
54
|
+
"control-character-reference" <=> ControlCharacterReference,
|
|
55
|
+
"end-tag-with-attributes" <=> EndTagWithAttributes,
|
|
56
|
+
"end-tag-with-trailing-solidus" <=> EndTagWithTrailingSolidus,
|
|
57
|
+
"eof-before-tag-name" <=> EofBeforeTagName,
|
|
58
|
+
"eof-in-cdata" <=> EofInCdata,
|
|
59
|
+
"eof-in-comment" <=> EofInComment,
|
|
60
|
+
"eof-in-doctype" <=> EofInDoctype,
|
|
61
|
+
"eof-in-script-html-comment-like-text" <=> EofInScriptHtmlCommentLikeText,
|
|
62
|
+
"eof-in-tag" <=> EofInTag,
|
|
63
|
+
"incorrectly-closed-comment" <=> IncorrectlyClosedComment,
|
|
64
|
+
"incorrectly-opened-comment" <=> IncorrectlyOpenedComment,
|
|
65
|
+
"invalid-character-sequence-after-doctype-name" <=> InvalidCharacterSequenceAfterDoctypeName,
|
|
66
|
+
"invalid-first-character-of-tag-name" <=> InvalidFirstCharacterOfTagName,
|
|
67
|
+
"missing-attribute-value" <=> MissingAttributeValue,
|
|
68
|
+
"missing-doctype-name" <=> MissingDoctypeName,
|
|
69
|
+
"missing-doctype-public-identifier" <=> MissingDoctypePublicIdentifier,
|
|
70
|
+
"missing-doctype-system-identifier" <=> MissingDoctypeSystemIdentifier,
|
|
71
|
+
"missing-end-tag-name" <=> MissingEndTagName,
|
|
72
|
+
"missing-quote-before-doctype-public-identifier" <=> MissingQuoteBeforeDoctypePublicIdentifier,
|
|
73
|
+
"missing-quote-before-doctype-system-identifier" <=> MissingQuoteBeforeDoctypeSystemIdentifier,
|
|
74
|
+
"missing-semicolon-after-character-reference" <=> MissingSemicolonAfterCharacterReference,
|
|
75
|
+
"missing-whitespace-after-doctype-public-keyword" <=> MissingWhitespaceAfterDoctypePublicKeyword,
|
|
76
|
+
"missing-whitespace-after-doctype-system-keyword" <=> MissingWhitespaceAfterDoctypeSystemKeyword,
|
|
77
|
+
"missing-whitespace-before-doctype-name" <=> MissingWhitespaceBeforeDoctypeName,
|
|
78
|
+
"missing-whitespace-between-attributes" <=> MissingWhitespaceBetweenAttributes,
|
|
79
|
+
"missing-whitespace-between-doctype-public-and-system-identifiers" <=> MissingWhitespaceBetweenDoctypePublicAndSystemIdentifiers,
|
|
80
|
+
"nested-comment" <=> NestedComment,
|
|
81
|
+
"noncharacter-character-reference" <=> NoncharacterCharacterReference,
|
|
82
|
+
"noncharacter-in-input-stream" <=> NoncharacterInInputStream,
|
|
83
|
+
"null-character-reference" <=> NullCharacterReference,
|
|
84
|
+
"surrogate-character-reference" <=> SurrogateCharacterReference,
|
|
85
|
+
"surrogate-in-input-stream" <=> SurrogateInInputStream,
|
|
86
|
+
"unexpected-character-after-doctype-system-identifier" <=> UnexpectedCharacterAfterDoctypeSystemIdentifier,
|
|
87
|
+
"unexpected-character-in-attribute-name" <=> UnexpectedCharacterInAttributeName,
|
|
88
|
+
"unexpected-character-in-unquoted-attribute-value" <=> UnexpectedCharacterInUnquotedAttributeValue,
|
|
89
|
+
"unexpected-equals-sign-before-attribute-name" <=> UnexpectedEqualsSignBeforeAttributeName,
|
|
90
|
+
"unexpected-null-character" <=> UnexpectedNullCharacter,
|
|
91
|
+
"unexpected-question-mark-instead-of-tag-name" <=> UnexpectedQuestionMarkInsteadOfTagName,
|
|
92
|
+
"unexpected-solidus-in-tag" <=> UnexpectedSolidusInTag,
|
|
93
|
+
"unknown-named-character-reference" <=> UnknownNamedCharacterReference,
|
|
94
|
+
"duplicate-attribute" <=> DuplicateAttribute,
|
|
95
|
+
"control-character-in-input-stream" <=> ControlCharacterInInputStream,
|
|
96
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
use std::borrow::{Borrow, BorrowMut};
|
|
2
|
+
use std::fmt::{Debug, Formatter};
|
|
3
|
+
use std::ops::{Deref, DerefMut};
|
|
4
|
+
|
|
5
|
+
/// A wrapper around a bytestring.
|
|
6
|
+
///
|
|
7
|
+
/// This newtype only exists to provide a nicer `Debug` impl
|
|
8
|
+
#[derive(Clone, Default, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
|
9
|
+
pub struct HtmlString(pub Vec<u8>);
|
|
10
|
+
|
|
11
|
+
impl Deref for HtmlString {
|
|
12
|
+
type Target = Vec<u8>;
|
|
13
|
+
|
|
14
|
+
fn deref(&self) -> &Self::Target {
|
|
15
|
+
&self.0
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
impl DerefMut for HtmlString {
|
|
20
|
+
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
21
|
+
&mut self.0
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
impl Debug for HtmlString {
|
|
26
|
+
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
|
|
27
|
+
write!(f, "b\"")?;
|
|
28
|
+
for &byte in &self.0 {
|
|
29
|
+
for ch in std::ascii::escape_default(byte) {
|
|
30
|
+
write!(f, "{}", ch as char)?;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
write!(f, "\"")
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
impl Borrow<[u8]> for HtmlString {
|
|
39
|
+
fn borrow(&self) -> &[u8] {
|
|
40
|
+
&self.0
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
impl BorrowMut<[u8]> for HtmlString {
|
|
45
|
+
fn borrow_mut(&mut self) -> &mut [u8] {
|
|
46
|
+
&mut self.0
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
impl AsRef<[u8]> for HtmlString {
|
|
51
|
+
fn as_ref(&self) -> &[u8] {
|
|
52
|
+
&self.0
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
impl<const N: usize> PartialEq<&[u8; N]> for HtmlString {
|
|
57
|
+
fn eq(&self, other: &&[u8; N]) -> bool {
|
|
58
|
+
self.0 == *other
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
impl<const N: usize> PartialEq<HtmlString> for &[u8; N] {
|
|
63
|
+
fn eq(&self, other: &HtmlString) -> bool {
|
|
64
|
+
other.0 == *self
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
impl PartialEq<&[u8]> for HtmlString {
|
|
69
|
+
fn eq(&self, other: &&[u8]) -> bool {
|
|
70
|
+
self.0 == *other
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
impl PartialEq<HtmlString> for &[u8] {
|
|
75
|
+
fn eq(&self, other: &HtmlString) -> bool {
|
|
76
|
+
*self == other.0
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
impl PartialEq<Vec<u8>> for HtmlString {
|
|
81
|
+
fn eq(&self, other: &Vec<u8>) -> bool {
|
|
82
|
+
self.0 == *other
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
impl PartialEq<HtmlString> for Vec<u8> {
|
|
87
|
+
fn eq(&self, other: &HtmlString) -> bool {
|
|
88
|
+
*self == other.0
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
#[test]
|
|
93
|
+
fn test_eq_html_str_and_byte_literal() {
|
|
94
|
+
assert!(HtmlString(b"hello world".to_vec()) == b"hello world");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#[test]
|
|
98
|
+
fn test_eq_byte_literal_and_html_str() {
|
|
99
|
+
assert!(b"hello world" == HtmlString(b"hello world".to_vec()));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[test]
|
|
103
|
+
fn test_eq_html_str_and_byte_slice() {
|
|
104
|
+
assert!(HtmlString(b"hello world".to_vec()) == b"hello world".as_slice());
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
#[test]
|
|
108
|
+
fn test_eq_byte_slice_and_html_str() {
|
|
109
|
+
assert!(b"hello world".as_slice() == HtmlString(b"hello world".to_vec()));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
#[test]
|
|
113
|
+
fn test_borrowing() {
|
|
114
|
+
use crate::StartTag;
|
|
115
|
+
// demonstrate a usecase for Borrow/BorrowMut
|
|
116
|
+
let tag = StartTag::<()>::default();
|
|
117
|
+
assert!(!tag.attributes.contains_key(b"href".as_slice()));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
impl From<Vec<u8>> for HtmlString {
|
|
121
|
+
fn from(vec: Vec<u8>) -> HtmlString {
|
|
122
|
+
HtmlString(vec)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
impl From<HtmlString> for Vec<u8> {
|
|
127
|
+
fn from(other: HtmlString) -> Vec<u8> {
|
|
128
|
+
other.0
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#![warn(missing_docs)]
|
|
2
|
+
// This is an HTML parser. HTML can be untrusted input from the internet.
|
|
3
|
+
#![forbid(unsafe_code)]
|
|
4
|
+
//
|
|
5
|
+
// Relative links in the README.md don't work in rustdoc, so we have to override them.
|
|
6
|
+
#![doc = concat!("[LICENSE]: ", blob_url_prefix!(), "LICENSE")]
|
|
7
|
+
#![doc = concat!("[examples/tokenize_with_state_switches.rs]: ", blob_url_prefix!(), "examples/tokenize_with_state_switches.rs")]
|
|
8
|
+
#![doc = concat!("[examples/custom_emitter.rs]: ", blob_url_prefix!(), "examples/custom_emitter.rs")]
|
|
9
|
+
#![doc = concat!("[examples/callback_emitter.rs]: ", blob_url_prefix!(), "examples/callback_emitter.rs")]
|
|
10
|
+
#![doc = concat!("[examples/scraper.rs]: ", blob_url_prefix!(), "examples/scraper.rs")]
|
|
11
|
+
#![cfg_attr(doc, doc = include_str!("../README.md"))]
|
|
12
|
+
//
|
|
13
|
+
#![warn(clippy::all)]
|
|
14
|
+
#![warn(
|
|
15
|
+
absolute_paths_not_starting_with_crate,
|
|
16
|
+
rustdoc::invalid_html_tags,
|
|
17
|
+
missing_copy_implementations,
|
|
18
|
+
missing_debug_implementations,
|
|
19
|
+
semicolon_in_expressions_from_macros,
|
|
20
|
+
unreachable_pub,
|
|
21
|
+
unused_extern_crates,
|
|
22
|
+
variant_size_differences
|
|
23
|
+
)]
|
|
24
|
+
#![allow(clippy::module_name_repetitions)]
|
|
25
|
+
#![allow(clippy::missing_errors_doc)]
|
|
26
|
+
|
|
27
|
+
macro_rules! blob_url_prefix {
|
|
28
|
+
() => {
|
|
29
|
+
concat!(
|
|
30
|
+
"https://github.com/untitaker/html5gum/blob/",
|
|
31
|
+
env!("CARGO_PKG_VERSION"),
|
|
32
|
+
"/"
|
|
33
|
+
)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// miraculously makes warnings disappear as blob_url_prefix is used in #![doc]
|
|
38
|
+
use blob_url_prefix;
|
|
39
|
+
|
|
40
|
+
mod arrayvec;
|
|
41
|
+
mod char_validator;
|
|
42
|
+
pub mod emitters;
|
|
43
|
+
mod entities;
|
|
44
|
+
mod error;
|
|
45
|
+
mod htmlstring;
|
|
46
|
+
mod machine;
|
|
47
|
+
mod machine_helper;
|
|
48
|
+
mod read_helper;
|
|
49
|
+
mod reader;
|
|
50
|
+
mod span;
|
|
51
|
+
mod state;
|
|
52
|
+
mod tokenizer;
|
|
53
|
+
mod utils;
|
|
54
|
+
|
|
55
|
+
#[cfg(debug_assertions)]
|
|
56
|
+
#[doc(hidden)]
|
|
57
|
+
pub mod testutils;
|
|
58
|
+
|
|
59
|
+
pub use emitters::default::{DefaultEmitter, Doctype, EndTag, StartTag, Token};
|
|
60
|
+
pub use emitters::{naive_next_state, Emitter, ForwardingEmitter};
|
|
61
|
+
pub use error::Error;
|
|
62
|
+
pub use htmlstring::HtmlString;
|
|
63
|
+
pub use reader::{IoReader, Readable, Reader, StringReader};
|
|
64
|
+
pub use span::{Span, SpanBound, Spanned};
|
|
65
|
+
pub use state::State;
|
|
66
|
+
pub use tokenizer::Tokenizer;
|