2 releases
new 0.1.1 | Mar 4, 2025 |
---|---|
0.1.0 | Mar 4, 2025 |
#450 in Algorithms
225KB
1K
SLoC
Sublime Color Scheme
This is a simple library to parse a sublime color scheme to a syntect::highlighting::Theme
.
I wrote this to use within my project quellcode, but other projects may find it useful.
Supported features
Colors
- Hex
- Hex with alpha
- Named
- RGB
- RGBA
- HSL
- HSLA
- HWB
- HWB with alpha
- Variables
- Color Modifiers
Adjusters
- Lightness
- Saturation
- Alpha
- Blend
- Blend Alpha
- Min Contrast
Min Contrast is supported but I'm im not sure if I implemented correctly. Please open an issue if it doesn't work.
TODO
- Foreground Adjust
Installation
Add this to your Cargo.toml
:
[dependencies]
sublime_color_scheme = "0.1.0"
Usage
use sublime_color_scheme::ColorScheme;
use syntect::highlighting::Theme;
use std::{path::Path, fs::read_to_string};
let path = Path::new("path/to/file.sublime-color-scheme");
let scheme = read_to_string(path).expect("Failed to read file");
let color_scheme = ColorScheme::from_str(&scheme).expect("Failed to parse theme");
// or
// let color_scheme = sublime_color_scheme::parse_color_scheme(&scheme).expect("Failed to parse theme");
// or
// let color_scheme = sublime_color_scheme::parse_color_scheme_file(path).expect("Failed to parse theme");
Theme::try_from(scheme).expect("Failed to convert to theme");
Contributing
Pull requests are welcome.
Some things that need to be done is add more unit tests.
If you do decide to contribute, it is recommended to follow the Conventional Commits specification when typing your commit messages, but it is not required.
Credits
Thanks to philpax for the original implementation.
See here for original
License
Dependencies
~4–11MB
~115K SLoC