chore: 0.0.7: bump deps & light code cleanup
This commit is contained in:
parent
5d18f9201e
commit
8b8047de37
2 changed files with 601 additions and 2114 deletions
|
|
@ -1,33 +1,33 @@
|
|||
[package]
|
||||
name = "sabry_intrnl"
|
||||
description = "Sabry internal, yet still public library"
|
||||
version.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
authors.workspace = true
|
||||
description = "Sabry internal, yet still public library"
|
||||
repository.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
syn.workspace = true
|
||||
raffia.workspace = true
|
||||
grass.workspace = true
|
||||
grass.optional = true
|
||||
lightningcss.workspace = true
|
||||
lightningcss.optional = true
|
||||
base64.workspace = true
|
||||
base64.optional = true
|
||||
|
||||
thiserror.workspace = true
|
||||
serde.workspace = true
|
||||
serde.features = ["derive"]
|
||||
toml.workspace = true
|
||||
cfg-if.workspace = true
|
||||
|
||||
[features]
|
||||
scope = ["dep:base64"]
|
||||
compile = ["dep:lightningcss", "dep:grass"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[dependencies]
|
||||
base64.workspace = true
|
||||
base64.optional = true
|
||||
grass.workspace = true
|
||||
grass.optional = true
|
||||
lightningcss.workspace = true
|
||||
lightningcss.optional = true
|
||||
raffia.workspace = true
|
||||
syn.workspace = true
|
||||
|
||||
cfg-if.workspace = true
|
||||
serde.workspace = true
|
||||
serde.features = ["derive"]
|
||||
thiserror.workspace = true
|
||||
toml.workspace = true
|
||||
|
||||
[features]
|
||||
compile = ["dep:grass", "dep:lightningcss"]
|
||||
scope = ["dep:base64"]
|
||||
|
|
|
|||
|
|
@ -377,35 +377,43 @@ impl ScopedSelector {
|
|||
|
||||
#[cfg(feature = "scope")]
|
||||
pub fn sanitize_css_member(source: &str) -> String {
|
||||
let mut target = String::with_capacity(source.len());
|
||||
let mut next_uppercase: bool = false;
|
||||
for (i, c) in source
|
||||
.chars()
|
||||
.filter(|c| c.is_alphanumeric() || *c == '-')
|
||||
.enumerate()
|
||||
{
|
||||
// first gidit is prepended with 'n'
|
||||
if i == 0 && c.is_numeric() {
|
||||
target.push('n');
|
||||
target.push(c);
|
||||
continue;
|
||||
let mut target = String::with_capacity(source.len() + 1);
|
||||
|
||||
for part in source.split('-').filter(|p| !p.is_empty()) {
|
||||
let mut chars = part.chars().filter(|c| c.is_ascii() && c.is_alphanumeric());
|
||||
match (chars.next(), chars.next()) {
|
||||
(None, None) => continue,
|
||||
(Some(f), None) => {
|
||||
target.push(f);
|
||||
continue;
|
||||
}
|
||||
(Some(f), Some(s)) => {
|
||||
target.push(f.to_ascii_uppercase());
|
||||
target.push(s);
|
||||
}
|
||||
(None, Some(s)) => {
|
||||
target.push(s);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// dash is omitted, replacing the next char with its uppercase
|
||||
if c == '-' {
|
||||
next_uppercase = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
let char = if next_uppercase {
|
||||
next_uppercase = false;
|
||||
c.to_ascii_uppercase()
|
||||
} else {
|
||||
c
|
||||
};
|
||||
|
||||
target.push(char);
|
||||
chars.for_each(|c| target.push(c));
|
||||
}
|
||||
|
||||
match target.chars().next() {
|
||||
Some(c) if c.is_numeric() => {
|
||||
target.insert(0, 'n');
|
||||
}
|
||||
Some(c) => {
|
||||
target.replace_range(..1, &c.to_ascii_lowercase().to_string());
|
||||
}
|
||||
_ => {
|
||||
/* has to produce valid rust ident */
|
||||
target.clear();
|
||||
target.push_str("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
target
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue