-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from TanX-009/main
feat(filter): add camel_case filter and auto_lightness filter
- Loading branch information
Showing
4 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use upon::Value; | ||
|
||
use crate::color::parse::check_string_value; | ||
|
||
pub fn camel_case(value: &Value) -> Result<String, String> { | ||
let string = check_string_value(value).unwrap(); | ||
|
||
let mut result = String::new(); | ||
let mut capitalize_next = false; | ||
|
||
for c in string.chars() { | ||
if c == '_' { | ||
capitalize_next = true; | ||
} else { | ||
if capitalize_next { | ||
result.push(c.to_uppercase().next().unwrap()); | ||
capitalize_next = false; | ||
} else { | ||
result.push(c); | ||
} | ||
} | ||
} | ||
|
||
debug!("Converting to camelCase: {} to {}", string, result); | ||
|
||
Ok(result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod alpha; | ||
pub mod camel; | ||
pub mod grayscale; | ||
pub mod hue; | ||
pub mod invert; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters