This project aims to implement a CSS(less like) parser in rust. Currently the code is targeting the PostCSS AST.

Overview

CSS(less like) parser written in rust (WIP)

This project aims to implement a CSS(less like) parser in rust. Currently the code is targeting the PostCSS AST.

Features:

Nestable CSS Standard

  • rule
  • prop
  • declaration
    • url
    • hex
    • string
    • number
    • calc
    • var
  • at rule
    • media query
    • import
    • keyframe
    • variable
  • selector
    • block
    • class
    • id
    • data attribute
    • &
    • ,
    • +
    • *
    • sudo class
  • comment
  • function?

Diagnostic

  • location
  • error report

APIs

  • transformer
  • generator
  • wasm

Example

  • input
@variable: #999;
@variable2: #fff;

main {
    color: #999;
    -webkit-line-clamp: 3;
    h3 {
        font-size: large;
        background: url("https://www.baidu.com");
    }
    [data-attr] {
        background-color: white;
        left: calc(100% - 10px);
    }
    &.img {
        width: fit-content;
    }
}

.test-class1 {
    color: white;
}
  • output
[
    Atrule {
        type: "atrule",
        name: "variable",
        params: "#999",
        value: Some(
            "#999",
        ),
    },
    Atrule {
        type: "atrule",
        name: "variable2",
        params: "#fff",
        value: Some(
            "#fff",
        ),
    },
    Rule {
        type: "rule",
        selector: "main",
        nodes: [
            Decl {
                type: "decl",
                prop: "color",
                value: "#999",
            },
            Decl {
                type: "decl",
                prop: "-webkit-line-clamp",
                value: "3",
            },
            Rule {
                type: "rule",
                selector: "h3",
                nodes: [
                    Decl {
                        type: "decl",
                        prop: "font-size",
                        value: "large",
                    },
                    Decl {
                        type: "decl",
                        prop: "background",
                        value: "url(\"https://www.baidu.com\")",
                    },
                ],
            },
            Rule {
                type: "rule",
                selector: "[data-attr]",
                nodes: [
                    Decl {
                        type: "decl",
                        prop: "background-color",
                        value: "white",
                    },
                    Decl {
                        type: "decl",
                        prop: "left",
                        value: "calc(100% - 10px)",
                    },
                ],
            },
            Rule {
                type: "rule",
                selector: "&.img",
                nodes: [
                    Decl {
                        type: "decl",
                        prop: "width",
                        value: "fit-content",
                    },
                ],
            },
        ],
    },
    Rule {
        type: "rule",
        selector: ".test-class1",
        nodes: [
            Decl {
                type: "decl",
                prop: "color",
                value: "white",
            },
        ],
    },
]
You might also like...
Rust query string parser with nesting support

What is Queryst? This is a fork of the original, with serde and serde_json updated to 0.9 A query string parsing library for Rust inspired by https://

Soon to be AsciiDoc parser implemented in rust!

pagliascii "But ASCII Doc, I am Pagliascii" Soon to be AsciiDoc parser implemented in rust! This project is the current implementation of the requeste

PEG parser for YAML written in Rust 🦀

yaml-peg PEG parser (pest) for YAML written in Rust 🦀 Quick Start ⚡️ # Run cargo run -- --file example_files/test.yaml # Output { "xmas": "true",

MRT/BGP data parser written in Rust.
MRT/BGP data parser written in Rust.

BGPKIT Parser BGPKIT Parser aims to provides the most ergonomic MRT/BGP message parsing Rust API. BGPKIT Parser has the following features: performant

A feature-few, no-allocation JSON parser in `no_std` rust.

Small JSON Parser in no_std This library reads and parses JSON strings. Its intended use case is to read a JSON payload once. It does not serialise da

A Gura parser for Rust

Gura Rust parser IMPORTANT: if you need to use Gura in a more user-friendly way, you have at your disposal Serde Gura which allows you to perform Seri

Front Matter parser for Rust.

fronma Front Matter parser for Rust. Usage Add this crate as a dependency: [dependencies] fronma = "~0.1" then use fronma::parser::parse to parse text

A Rust crate for LL(k) parser combinators.

oni-comb-rs (鬼昆布,おにこんぶ) A Rust crate for LL(k) parser combinators. Main project oni-comb-parser-rs Sub projects The following is projects implemented

gors is an experimental go toolchain written in rust (parser, compiler).

gors gors is an experimental go toolchain written in rust (parser, compiler). Install Using git This method requires the Rust toolchain to be installe

Owner
Huang Liuhaoran
TS/Rust lover; Senior frontend developer with expanded skills in graphic design, music composition and sound design
Huang Liuhaoran
A CSS parser, transformer, and minifier written in Rust.

@parcel/css A CSS parser, transformer, and minifier written in Rust. Features Extremely fast – Parsing and minifying large files is completed in milli

Parcel 3.1k Jan 9, 2023
Yet Another Parser library for Rust. A lightweight, dependency free, parser combinator inspired set of utility methods to help with parsing strings and slices.

Yap: Yet another (rust) parsing library A lightweight, dependency free, parser combinator inspired set of utility methods to help with parsing input.

James Wilson 117 Dec 14, 2022
Website for Microformats Rust parser (using 'microformats-parser'/'mf2')

Website for Microformats Rust parser (using 'microformats-parser'/'mf2')

Microformats 5 Jul 19, 2022
A typed parser generator embedded in Rust code for Parsing Expression Grammars

Oak Compiled on the nightly channel of Rust. Use rustup for managing compiler channels. You can download and set up the exact same version of the comp

Pierre Talbot 138 Nov 25, 2022
A native Rust port of Google's robots.txt parser and matcher C++ library.

robotstxt A native Rust port of Google's robots.txt parser and matcher C++ library. Native Rust port, no third-part crate dependency Zero unsafe code

Folyd 72 Dec 11, 2022
Rust parser combinator framework

nom, eating data byte by byte nom is a parser combinators library written in Rust. Its goal is to provide tools to build safe parsers without compromi

Geoffroy Couprie 7.6k Jan 7, 2023
Parsing Expression Grammar (PEG) parser generator for Rust

Parsing Expression Grammars in Rust Documentation | Release Notes rust-peg is a simple yet flexible parser generator that makes it easy to write robus

Kevin Mehall 1.2k Dec 30, 2022
A fast monadic-style parser combinator designed to work on stable Rust.

Chomp Chomp is a fast monadic-style parser combinator library designed to work on stable Rust. It was written as the culmination of the experiments de

Martin Wernstål 228 Oct 31, 2022
A parser combinator library for Rust

combine An implementation of parser combinators for Rust, inspired by the Haskell library Parsec. As in Parsec the parsers are LL(1) by default but th

Markus Westerlind 1.1k Dec 28, 2022
LR(1) parser generator for Rust

LALRPOP LALRPOP is a Rust parser generator framework with usability as its primary goal. You should be able to write compact, DRY, readable grammars.

null 2.4k Jan 7, 2023