Skip to content

A lightweight and non-strict CSS parser based on Regular Expressions that generates a lightweight AST, designed for CSS-in-JS

Notifications You must be signed in to change notification settings

UpperCod/css-to-object

Repository files navigation

css-to-object

css-to-object is a package that transforms the syntax from css to JSON format using regular expressions

The result is an object that shows properties, selectors and nests, example:

input css

.a {
    width: 200px;
    .b {
        font-size: 100px;
        &:hover {
            background: teal;
        }
    }
}

@media (max-width: 200px) {
    .b {
        font-size: 100px;
    }
}

output css

{
    ":host": {
        ".a ": {
            "width": "200px",
            ".b ": {
                "font-size": "100px",
                "&:hover ": { "background": "teal" }
            }
        },
        "@media (max-width: 200px) ": { ".b ": { "font-size": "100px" } }
    }
}

Note that the output is encapsulated in a :host selector.

About

A lightweight and non-strict CSS parser based on Regular Expressions that generates a lightweight AST, designed for CSS-in-JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published