A tool for seamlessly transforming standard CSS into Grimoire CSS spells.
grimoire_css_transmutator is available both as a CLI tool and as a Rust library crate. It helps you convert your CSS files or inline CSS content into a structured JSON format suitable for use with the Grimoire CSS system.
- Batch conversion: Process multiple CSS files or patterns at once.
- Inline content: Convert CSS provided as a string.
- Flexible output: Save results to a file or print to stdout.
- Oneliner support: Optionally include a one-line representation for each class.
You need Rust installed.
cargo install --path .grimoire_css_transmutator [OPTIONS] [INPUT]-p,--pathsProcess comma-separated list of CSS file paths or glob patterns-c,--contentProcess CSS content provided as a string-o,--outputSpecify output file (default:./grimoire/transmuted.json)-l,--with-onelinerIncludeonelinerproperty in output (default: disabled)-h,--helpDisplay help message
Convert multiple CSS files:
grimoire_css_transmutator -p styles.css,components.cssConvert all CSS files in a directory:
grimoire_css_transmutator -p "src/**/*.css"Convert inline CSS content:
grimoire_css_transmutator -c '.button { color: red; }' -lCustom output file:
grimoire_css_transmutator -p '*.css' -o custom_output.json --with-onelinerThe output is a JSON file (or stdout) containing an array of objects, each representing a CSS class and its corresponding Grimoire CSS spells. Example:
{
"scrolls": [
{
"name": "button",
"spells": ["color=red"],
"oneliner": ".button { color: red; }"
}
]
}You can use grimoire_css_transmutator both as a command-line tool and as a Rust library crate.
Add grimoire_css_transmutator_lib to your Cargo.toml dependencies and use it in your Rust code:
use grimoire_css_transmutator_lib::transmute_from_content;
let (duration, json) = transmute_from_content(".foo { color: blue; }", false).unwrap();
println!("{}", json);MIT