| Crates.io | rust-less |
| lib.rs | rust-less |
| version | 0.1.0 |
| created_at | 2025-05-08 08:22:34.075339+00 |
| updated_at | 2025-05-08 08:22:34.075339+00 |
| description | A LESS to CSS parser and converter library written in Rust |
| homepage | |
| repository | https://github.com/YangChengxxyy/rust-less |
| max_upload_size | |
| id | 1665028 |
| size | 50,057 |
一个用 Rust 编写的 LESS 到 CSS 解析器和转换器库。
将下面的内容添加到你的 Cargo.toml 文件中:
[dependencies]
rust_less = "0.1.0"
use rust_less::parse_less;
fn main() {
let less_code = r#"
@primary-color: #333;
.container {
@width: 80%;
width: @width;
background-color: @primary-color;
.header {
color: blue;
}
}
"#;
match parse_less(less_code) {
Ok(css) => println!("转换后的 CSS: \n{}", css),
Err(e) => eprintln!("转换出错: {}", e),
}
}
# 安装命令行工具
cargo install rust-less --features cli
# 转换 LESS 文件为 CSS
rust-less style.less # 将生成 style.css
parse_less(source: &str) -> Result<String, String>解析 LESS 字符串并转换为 CSS。
parse_less_file(file_path: &str) -> Result<String, String>从文件中解析 LESS 并转换为 CSS。
MIT