@csstools/custom-function-parser
v2.0.0
Published
Parse CSS custom function definitions and calls.
Readme
Custom Function Parser
Implemented from : https://drafts.csswg.org/css-mixins-1/
Usage
Add Custom Function Parser to your project:
npm install @csstools/custom-function-parser @csstools/css-parser-algorithms @csstools/css-tokenizer --save-devCustom Function Parser depends on our CSS tokenizer and parser algorithms.
It must be used together with @csstools/css-tokenizer and @csstools/css-parser-algorithms.
import { parse } from '@csstools/custom-function-parser';
const customFunction = parse('--foo(--bar <length>: 1px) returns <length>');parse()parses a@functionprelude.parseFunctionParameters()parses a@mixinor@functionparameter list.parseDashedFunctionArguments()parses the arguments of a<dashed-function>call from its component values.
All parsing functions return false when the input is invalid.
onParseError only reports tokenizer and component value parsing errors.
The parameters and return type are not validated as <syntax> yet.
Their types are preserved as syntax strings and can be validated by the consumer.
