text_view: Use simple-minify-html instead of minify-html. (#1134)

To avoid depends on lightningcss, this is a heavy crate.

Ref #1132 

```
cargo bloat --release -n 200  --crates
    Finished `release` profile [optimized] target(s) in 0.30s
    Analyzing target/release/story

 File  .text     Size Crate
 4.6%  16.9%   3.4MiB lightningcss
```
This commit is contained in:
Jason Lee 2025-08-14 13:54:00 +08:00 committed by GitHub
parent c86b0222ce
commit a73273a0f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 284 deletions

310
Cargo.lock generated
View file

@ -76,15 +76,6 @@ dependencies = [
"zerocopy 0.7.35",
]
[[package]]
name = "aho-corasick"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
[[package]]
name = "aho-corasick"
version = "1.1.3"
@ -311,7 +302,7 @@ dependencies = [
"proc-macro2",
"pulldown-cmark",
"quote",
"rustc-hash 2.1.0",
"rustc-hash 2.1.1",
"serde",
"serde_derive",
"syn 2.0.101",
@ -706,15 +697,6 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64-simd"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "781dd20c3aff0bd194fe7d2a977dd92f21c173891f3a03b677359e5fa457e5d5"
dependencies = [
"simd-abstraction",
]
[[package]]
name = "basic-toml"
version = "0.1.10"
@ -733,7 +715,7 @@ dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.10.5",
"itertools 0.12.1",
"lazy_static",
"lazycell",
"log",
@ -756,13 +738,13 @@ dependencies = [
"bitflags 2.9.1",
"cexpr",
"clang-sys",
"itertools 0.10.5",
"itertools 0.13.0",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash 2.1.0",
"rustc-hash 2.1.1",
"shlex",
"syn 2.0.101",
]
@ -1435,7 +1417,7 @@ version = "0.1.0"
source = "git+https://github.com/zed-industries/zed.git#d6022dc87ceb2fd83ffbee062db82610901c8c7b"
dependencies = [
"indexmap 2.9.0",
"rustc-hash 2.1.0",
"rustc-hash 2.1.1",
"workspace-hack",
]
@ -1513,41 +1495,12 @@ dependencies = [
"tiny-keccak",
]
[[package]]
name = "const-str"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21077772762a1002bb421c3af42ac1725fa56066bfc53d9a55bb79905df2aaf3"
dependencies = [
"const-str-proc-macro",
]
[[package]]
name = "const-str-proc-macro"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e1e0fdd2e5d3041e530e1b21158aeeef8b5d0e306bc5c1e3d6cf0930d10e25a"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "convert_case"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "convert_case"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "cookie"
version = "0.18.1"
@ -1811,28 +1764,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "cssparser"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be934d936a0fbed5bcdc01042b770de1398bf79d0e192f49fa7faea0e99281e"
dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa 1.0.11",
"phf 0.11.3",
"smallvec",
]
[[package]]
name = "cssparser-color"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "556c099a61d85989d7af52b692e35a8d68a57e7df8c6d07563dc0778b3960c9f"
dependencies = [
"cssparser 0.33.0",
]
[[package]]
name = "cssparser-macros"
version = "0.6.1"
@ -1915,34 +1846,6 @@ dependencies = [
"syn 2.0.101",
]
[[package]]
name = "dashmap"
version = "5.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [
"cfg-if",
"hashbrown 0.14.5",
"lock_api",
"once_cell",
"parking_lot_core",
]
[[package]]
name = "data-encoding"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
[[package]]
name = "data-url"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a30bfce702bcfa94e906ef82421f2c0e61c076ad76030c16ee5d2e9a32fe193"
dependencies = [
"matches",
]
[[package]]
name = "data-url"
version = "0.3.1"
@ -1980,7 +1883,7 @@ version = "0.99.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce"
dependencies = [
"convert_case 0.4.0",
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
@ -3068,7 +2971,7 @@ version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19"
dependencies = [
"aho-corasick 1.1.3",
"aho-corasick",
"bstr",
"log",
"regex-automata 0.4.8",
@ -3249,7 +3152,6 @@ dependencies = [
"itertools 0.13.0",
"markdown",
"markup5ever_rcdom",
"minify-html",
"num-traits",
"once_cell",
"palette",
@ -3262,6 +3164,7 @@ dependencies = [
"serde",
"serde_json",
"serde_repr",
"simple-minify-html",
"smallvec",
"smol 1.3.0",
"tracing",
@ -3433,16 +3336,6 @@ dependencies = [
"ahash 0.7.8",
]
[[package]]
name = "hashbrown"
version = "0.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
dependencies = [
"ahash 0.8.11",
"bumpalo",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
@ -3957,15 +3850,6 @@ version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.11.0"
@ -4100,7 +3984,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e4755b7b995046f510a7520c42b2fed58b77bd94d5a87a8eb43d2fd126da8"
dependencies = [
"cssparser 0.27.2",
"cssparser",
"html5ever 0.26.0",
"indexmap 1.9.3",
"matches",
@ -4197,45 +4081,6 @@ dependencies = [
"redox_syscall 0.5.7",
]
[[package]]
name = "lightningcss"
version = "1.0.0-alpha.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a75fcbcdbcc84fc1ae7c60c31f99337560b620757a9bfc1c9f84df3cff8ac24"
dependencies = [
"ahash 0.8.11",
"bitflags 2.9.1",
"const-str",
"cssparser 0.33.0",
"cssparser-color",
"dashmap",
"data-encoding",
"getrandom 0.2.15",
"indexmap 2.9.0",
"itertools 0.10.5",
"lazy_static",
"lightningcss-derive",
"parcel_selectors",
"parcel_sourcemap",
"paste",
"pathdiff",
"rayon",
"serde",
"smallvec",
]
[[package]]
name = "lightningcss-derive"
version = "1.0.0-alpha.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12744d1279367caed41739ef094c325d53fb0ffcd4f9b84a368796f870252"
dependencies = [
"convert_case 0.6.0",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "linux-raw-sys"
version = "0.3.8"
@ -4511,47 +4356,6 @@ dependencies = [
"unicase",
]
[[package]]
name = "minify-html"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd4517942a8e7425c990b14977f86a63e4996eed7b15cfcca1540126ac5ff25"
dependencies = [
"aho-corasick 0.7.20",
"lazy_static",
"lightningcss",
"memchr",
"minify-html-common",
"minify-js",
"once_cell",
"rustc-hash 1.1.0",
]
[[package]]
name = "minify-html-common"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "697a6b40dffdc5de10c0cbd709dc2bc2039cea9dab8aaa636eb9a49d6b411780"
dependencies = [
"aho-corasick 0.7.20",
"itertools 0.12.1",
"lazy_static",
"memchr",
"rustc-hash 1.1.0",
"serde",
"serde_json",
]
[[package]]
name = "minify-js"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22d6c512a82abddbbc13b70609cb2beff01be2c7afff534d6e5e1c85e438fc8b"
dependencies = [
"lazy_static",
"parse-js",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
@ -4890,7 +4694,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [
"proc-macro-crate 1.3.1",
"proc-macro-crate 3.2.0",
"proc-macro2",
"quote",
"syn 2.0.101",
@ -5381,12 +5185,6 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "outref"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f222829ae9293e33a9f5e9f440c6760a3d450a64affe1846486b140db81c1f4"
[[package]]
name = "overload"
version = "0.1.1"
@ -5451,36 +5249,6 @@ dependencies = [
"system-deps",
]
[[package]]
name = "parcel_selectors"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dccbc6fb560df303a44e511618256029410efbc87779018f751ef12c488271fe"
dependencies = [
"bitflags 2.9.1",
"cssparser 0.33.0",
"log",
"phf 0.11.3",
"phf_codegen 0.11.3",
"precomputed-hash",
"rustc-hash 2.1.0",
"smallvec",
]
[[package]]
name = "parcel_sourcemap"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "485b74d7218068b2b7c0e3ff12fbc61ae11d57cb5d8224f525bd304c6be05bbb"
dependencies = [
"base64-simd",
"data-url 0.1.1",
"rkyv",
"serde",
"serde_json",
"vlq",
]
[[package]]
name = "parking"
version = "2.2.1"
@ -5510,19 +5278,6 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "parse-js"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ec3b11d443640ec35165ee8f6f0559f1c6f41878d70330fe9187012b5935f02"
dependencies = [
"aho-corasick 0.7.20",
"bumpalo",
"hashbrown 0.13.2",
"lazy_static",
"memchr",
]
[[package]]
name = "paste"
version = "1.0.15"
@ -6067,7 +5822,7 @@ dependencies = [
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash 2.1.0",
"rustc-hash 2.1.1",
"rustls",
"socket2 0.5.9",
"thiserror 2.0.12",
@ -6085,7 +5840,7 @@ dependencies = [
"getrandom 0.2.15",
"rand 0.8.5",
"ring",
"rustc-hash 2.1.0",
"rustc-hash 2.1.1",
"rustls",
"rustls-pki-types",
"slab",
@ -6414,7 +6169,7 @@ version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick 1.1.3",
"aho-corasick",
"memchr",
"regex-automata 0.4.8",
"regex-syntax 0.8.5",
@ -6435,7 +6190,7 @@ version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
dependencies = [
"aho-corasick 1.1.3",
"aho-corasick",
"memchr",
"regex-syntax 0.8.5",
]
@ -6765,9 +6520,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.1.0"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "rustc_version"
@ -7112,7 +6867,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df320f1889ac4ba6bc0cdc9c9af7af4bd64bb927bccdf32d81140dc1f9be12fe"
dependencies = [
"bitflags 1.3.2",
"cssparser 0.27.2",
"cssparser",
"derive_more",
"fxhash",
"log",
@ -7333,15 +7088,6 @@ dependencies = [
"libc",
]
[[package]]
name = "simd-abstraction"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cadb29c57caadc51ff8346233b5cec1d240b68ce55cf1afc764818791876987"
dependencies = [
"outref",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
@ -7363,6 +7109,20 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
[[package]]
name = "simple-minify-html"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2e14af458c754ee7a0fc21fbb93b824101e2c13a6bd5dc94a32c156a773e36"
dependencies = [
"aho-corasick",
"itertools 0.14.0",
"memchr",
"rustc-hash 2.1.1",
"serde",
"serde_json",
]
[[package]]
name = "simplecss"
version = "0.2.1"
@ -8910,7 +8670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ac8e0e3e4696253dc06167990b3fe9a2668ab66270adf949a464db4088cb354"
dependencies = [
"base64",
"data-url 0.3.1",
"data-url",
"flate2",
"fontdb 0.23.0",
"imagesize",
@ -9059,12 +8819,6 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "vlq"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65dd7eed29412da847b0f78bcec0ac98588165988a8cfe41d4ea1d429f8ccfff"
[[package]]
name = "vswhom"
version = "0.1.0"

View file

@ -1,12 +1,12 @@
[package]
name = "gpui-component"
description = "UI components for building fantastic desktop application by using GPUI."
version = "0.1.0"
edition = "2021"
homepage = "https://github.com/longbridge/gpui-component"
keywords = ["GPUI", "application", "desktop", "ui"]
license-file = "LICENSE-APACHE"
name = "gpui-component"
publish = true
version = "0.1.0"
[lib]
doctest = false
@ -53,7 +53,7 @@ markdown = "1.0.0-alpha.22"
# HTML Parser
html5ever = "0.27"
markup5ever_rcdom = "0.3.0"
minify-html = "0.15.0"
simple-minify-html = "0.17.2"
# Calendar
chrono = "0.4.38"

View file

@ -83,9 +83,11 @@ pub(super) fn parse_html(source: &str) -> Result<element::Node, SharedString> {
}
fn cleanup_html(source: &str) -> Vec<u8> {
let mut cfg = minify_html::Cfg::default();
cfg.keep_closing_tags = true;
minify_html::minify(source.as_bytes(), &cfg)
let cfg = simple_minify_html::Cfg {
keep_closing_tags: true,
..Default::default()
};
simple_minify_html::minify(&source.as_bytes(), Some(cfg)).to_vec()
}
#[derive(Clone)]