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,109 @@
|
|
|
1
|
+
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
|
|
2
|
+
#
|
|
3
|
+
# When uploading crates to the registry Cargo will automatically
|
|
4
|
+
# "normalize" Cargo.toml files for maximal compatibility
|
|
5
|
+
# with all versions of Cargo and also rewrite `path` dependencies
|
|
6
|
+
# to registry (e.g., crates.io) dependencies.
|
|
7
|
+
#
|
|
8
|
+
# If you are reading this file be aware that the original Cargo.toml
|
|
9
|
+
# will likely look very different (and much more reasonable).
|
|
10
|
+
# See Cargo.toml.orig for the original contents.
|
|
11
|
+
|
|
12
|
+
[package]
|
|
13
|
+
edition = "2018"
|
|
14
|
+
name = "html5gum"
|
|
15
|
+
version = "0.8.4"
|
|
16
|
+
authors = ["Markus Unterwaditzer <markus-honeypot@unterwaditzer.net>"]
|
|
17
|
+
build = false
|
|
18
|
+
include = [
|
|
19
|
+
"src/**/*",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"README.md",
|
|
22
|
+
"benches",
|
|
23
|
+
]
|
|
24
|
+
autolib = false
|
|
25
|
+
autobins = false
|
|
26
|
+
autoexamples = false
|
|
27
|
+
autotests = false
|
|
28
|
+
autobenches = false
|
|
29
|
+
description = "A WHATWG-compliant HTML5 tokenizer and tag soup parser."
|
|
30
|
+
readme = "README.md"
|
|
31
|
+
keywords = [
|
|
32
|
+
"html",
|
|
33
|
+
"html5",
|
|
34
|
+
"whatwg",
|
|
35
|
+
"parser",
|
|
36
|
+
"tokenizer",
|
|
37
|
+
]
|
|
38
|
+
categories = [
|
|
39
|
+
"parser-implementations",
|
|
40
|
+
"web-programming",
|
|
41
|
+
]
|
|
42
|
+
license = "MIT"
|
|
43
|
+
repository = "https://github.com/untitaker/html5gum"
|
|
44
|
+
|
|
45
|
+
[features]
|
|
46
|
+
afl-ijon = ["afl"]
|
|
47
|
+
default = ["jetscii"]
|
|
48
|
+
tree-builder = ["html5ever"]
|
|
49
|
+
|
|
50
|
+
[lib]
|
|
51
|
+
name = "html5gum"
|
|
52
|
+
path = "src/lib.rs"
|
|
53
|
+
bench = false
|
|
54
|
+
|
|
55
|
+
[[bench]]
|
|
56
|
+
name = "files"
|
|
57
|
+
path = "benches/files.rs"
|
|
58
|
+
harness = false
|
|
59
|
+
|
|
60
|
+
[[bench]]
|
|
61
|
+
name = "patterns"
|
|
62
|
+
path = "benches/patterns.rs"
|
|
63
|
+
harness = false
|
|
64
|
+
|
|
65
|
+
[dependencies.afl]
|
|
66
|
+
version = "0.17.0"
|
|
67
|
+
optional = true
|
|
68
|
+
|
|
69
|
+
[dependencies.html5ever]
|
|
70
|
+
version = "0.29.0"
|
|
71
|
+
optional = true
|
|
72
|
+
|
|
73
|
+
[dependencies.jetscii]
|
|
74
|
+
version = "0.5.1"
|
|
75
|
+
optional = true
|
|
76
|
+
|
|
77
|
+
[dev-dependencies.annotate-snippets]
|
|
78
|
+
version = "0.11.5"
|
|
79
|
+
|
|
80
|
+
[dev-dependencies.argh]
|
|
81
|
+
version = "0.1.12"
|
|
82
|
+
|
|
83
|
+
[dev-dependencies.glob]
|
|
84
|
+
version = "0.3.0"
|
|
85
|
+
|
|
86
|
+
[dev-dependencies.libtest-mimic]
|
|
87
|
+
version = "0.8.1"
|
|
88
|
+
|
|
89
|
+
[dev-dependencies.markup5ever_rcdom]
|
|
90
|
+
version = "0.5.0-unofficial"
|
|
91
|
+
|
|
92
|
+
[dev-dependencies.pretty_assertions]
|
|
93
|
+
version = "1.0.0"
|
|
94
|
+
|
|
95
|
+
[dev-dependencies.scraper]
|
|
96
|
+
version = "0.21.0"
|
|
97
|
+
|
|
98
|
+
[dev-dependencies.serde]
|
|
99
|
+
version = "1.0.130"
|
|
100
|
+
features = ["derive"]
|
|
101
|
+
|
|
102
|
+
[dev-dependencies.serde_bytes]
|
|
103
|
+
version = "0.11.5"
|
|
104
|
+
|
|
105
|
+
[dev-dependencies.serde_json]
|
|
106
|
+
version = "1.0.71"
|
|
107
|
+
|
|
108
|
+
[dev-dependencies.test-generator]
|
|
109
|
+
version = "0.3.0"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2021 Markus Unterwaditzer
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
SOFTWARE.
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# html5gum
|
|
2
|
+
|
|
3
|
+
[](https://docs.rs/html5gum)
|
|
4
|
+
[](https://crates.io/crates/html5gum)
|
|
5
|
+
|
|
6
|
+
`html5gum` is a WHATWG-compliant HTML tokenizer.
|
|
7
|
+
|
|
8
|
+
```rust
|
|
9
|
+
use std::fmt::Write;
|
|
10
|
+
use html5gum::{Tokenizer, Token};
|
|
11
|
+
|
|
12
|
+
let html = "<title >hello world</title>";
|
|
13
|
+
let mut new_html = String::new();
|
|
14
|
+
|
|
15
|
+
for Ok(token) in Tokenizer::new(html) {
|
|
16
|
+
match token {
|
|
17
|
+
Token::StartTag(tag) => {
|
|
18
|
+
write!(new_html, "<{}>", String::from_utf8_lossy(&tag.name)).unwrap();
|
|
19
|
+
}
|
|
20
|
+
Token::String(hello_world) => {
|
|
21
|
+
write!(new_html, "{}", String::from_utf8_lossy(&hello_world)).unwrap();
|
|
22
|
+
}
|
|
23
|
+
Token::EndTag(tag) => {
|
|
24
|
+
write!(new_html, "</{}>", String::from_utf8_lossy(&tag.name)).unwrap();
|
|
25
|
+
}
|
|
26
|
+
_ => panic!("unexpected input"),
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
assert_eq!(new_html, "<title>hello world</title>");
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`html5gum` provides multiple kinds of APIs:
|
|
34
|
+
|
|
35
|
+
* Iterating over tokens as shown above.
|
|
36
|
+
* Implementing your own `Emitter` for maximum performance, see [the `custom_emitter.rs` example][examples/custom_emitter.rs].
|
|
37
|
+
* A callbacks-based API for a middleground between convenience and performance, see [the `callback_emitter.rs` example][examples/callback_emitter.rs].
|
|
38
|
+
* With the `tree-builder` feature, html5gum can be integrated with `html5ever` and `scraper`. See [the `scraper.rs` example][examples/scraper.rs].
|
|
39
|
+
|
|
40
|
+
## What a tokenizer does and what it does not do
|
|
41
|
+
|
|
42
|
+
`html5gum` fully implements [13.2.5 of the WHATWG HTML
|
|
43
|
+
spec](https://html.spec.whatwg.org/#tokenization), i.e. is able to tokenize HTML documents and passes [html5lib's tokenizer
|
|
44
|
+
test suite](https://github.com/html5lib/html5lib-tests/tree/master/tokenizer). Since it is just a tokenizer, this means:
|
|
45
|
+
|
|
46
|
+
* `html5gum` **does not** [implement charset
|
|
47
|
+
detection.](https://html.spec.whatwg.org/#determining-the-character-encoding)
|
|
48
|
+
This implementation takes and returns bytes, but assumes UTF-8. It recovers
|
|
49
|
+
gracefully from invalid UTF-8.
|
|
50
|
+
* `html5gum` **does not** [correct mis-nested
|
|
51
|
+
tags.](https://html.spec.whatwg.org/#an-introduction-to-error-handling-and-strange-cases-in-the-parser)
|
|
52
|
+
* `html5gum` doesn't implement the DOM, and unfortunately in the HTML spec,
|
|
53
|
+
constructing the DOM ("tree construction") influences how tokenization is
|
|
54
|
+
done. For an example of which problems this causes see [this example
|
|
55
|
+
code][examples/tokenize_with_state_switches.rs].
|
|
56
|
+
* `html5gum` **does not** generally qualify as a browser-grade HTML *parser* as
|
|
57
|
+
per the WHATWG spec. This can change in the future, see [issue
|
|
58
|
+
21](https://github.com/untitaker/html5gum/issues/21).
|
|
59
|
+
|
|
60
|
+
With those caveats in mind, `html5gum` can pretty much ~parse~ _tokenize_
|
|
61
|
+
anything that browsers can. However, using the experimental `tree-builder`
|
|
62
|
+
feature, html5gum can be integrated with `html5ever` and `scraper`. See [the
|
|
63
|
+
`scraper.rs` example][examples/scraper.rs].
|
|
64
|
+
|
|
65
|
+
## Other features
|
|
66
|
+
|
|
67
|
+
* No unsafe Rust
|
|
68
|
+
* Only dependency is `jetscii`, and can be disabled via crate features (see `Cargo.toml`)
|
|
69
|
+
|
|
70
|
+
## Alternative HTML parsers
|
|
71
|
+
|
|
72
|
+
`html5gum` was created out of a need to parse HTML tag soup efficiently. Previous options were to:
|
|
73
|
+
|
|
74
|
+
* use [quick-xml](https://github.com/tafia/quick-xml/) or
|
|
75
|
+
[xmlparser](https://github.com/RazrFalcon/xmlparser) with some hacks to make
|
|
76
|
+
either one not choke on bad HTML. For some (rather large) set of HTML input
|
|
77
|
+
this works well (particularly `quick-xml` can be configured to be very
|
|
78
|
+
lenient about parsing errors) and parsing speed is stellar. But neither can
|
|
79
|
+
parse all HTML.
|
|
80
|
+
|
|
81
|
+
For my own usecase `html5gum` is about 2x slower than `quick-xml`.
|
|
82
|
+
|
|
83
|
+
* use [html5ever's own
|
|
84
|
+
tokenizer](https://docs.rs/html5ever/0.25.1/html5ever/tokenizer/index.html)
|
|
85
|
+
to avoid as much tree-building overhead as possible. This was functional but
|
|
86
|
+
had poor performance for my own usecase (10-15x slower than `quick-xml`).
|
|
87
|
+
|
|
88
|
+
* use [lol-html](https://github.com/cloudflare/lol-html), which would probably
|
|
89
|
+
perform at least as well as `html5gum`, but comes with a closure-based API
|
|
90
|
+
that I didn't manage to get working for my usecase.
|
|
91
|
+
|
|
92
|
+
## Etymology
|
|
93
|
+
|
|
94
|
+
Why is this library called `html5gum`?
|
|
95
|
+
|
|
96
|
+
* G.U.M: **G**iant **U**nreadable **M**atch-statement
|
|
97
|
+
|
|
98
|
+
* \<insert "how it feels to <s>chew 5 gum</s> _parse HTML_" meme here\>
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
Licensed under the MIT license, see [`./LICENSE`][LICENSE].
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
<!-- These link destinations are defined like this so that src/lib.rs can override them. -->
|
|
106
|
+
[LICENSE]: ./LICENSE
|
|
107
|
+
[examples/tokenize_with_state_switches.rs]: ./examples/tokenize_with_state_switches.rs
|
|
108
|
+
[examples/custom_emitter.rs]: ./examples/custom_emitter.rs
|
|
109
|
+
[examples/callback_emitter.rs]: ./examples/callback_emitter.rs
|
|
110
|
+
[examples/scraper.rs]: ./examples/scraper.rs
|