0.4.2 • Published 2 years ago

@uppercod/parse v0.4.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@uppercod/parse

utilities for text analysis

parse-css-params

Capture the parameters using the css parameter syntax, example:

import { parseCssParams } from "@uppercod/parse/parse-css-params";

parseCssParams(`var(--z, var(--x)) url("background.jpg")`);

Output

[
    [
        ["var", ["--z", "var(--x)"]],
        ["url", ["background.jpg"]]
    ]
]

parse-css-tokens

captures the properties of a string and associates them to an object, the capture allows associating useful meta tags to document or group the tokens

import { createTokens } from "@uppercod/parse/parse-css-tokens";

const { tokenize, tokens } = createTokens({ prefix: "fm--" });

tokenize`
    @title: Colors
    @description: UI colors;
    primary: red;
    secondary: black;
`;
/**
 * @output
 * --my-property: var(--fm--my-property, red);
 */

console.log(tokens);
/**
 * @output
 * {
 *    "Colors": {
 *        "title": "Colors",
 *        "description": "UI colors",
 *        "children": [["--fm--my-property", "red"]]
 *    }
 * }
 */

the regular expression is weak when capturing the parameters, so the metadata cannot include property type characters such as : and ;.

0.4.1

2 years ago

0.4.2

2 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.0

3 years ago