@@ -23,23 +23,23 @@ $ deno add @tbela99/css-parser
2323## Features
2424
2525- no dependency
26- - validate CSS based upon mdn-data
27- - generate CSS module output
28- - fault-tolerant parser, will try to fix invalid tokens according to the CSS syntax module 3 recommendations.
26+ - CSS validation based upon mdn-data
27+ - CSS modules support
28+ - fault-tolerant parser implementing the CSS syntax module 3 recommendations.
2929- fast and efficient minification without unsafe transforms,
3030 see [ benchmark] ( https://tbela99.github.io/css-parser/benchmark/index.html )
31- - minify colors: color(), lab(), lch(), oklab(), oklch(), color-mix(), light-dark(), system colors and
31+ - colors minification : color(), lab(), lch(), oklab(), oklch(), color-mix(), light-dark(), system colors and
3232 relative color
33- - generate nested css rules
34- - convert nested css rules to legacy syntax
35- - convert colors to any supported color format
36- - generate sourcemap
37- - compute css shorthands. see supported properties list below
38- - minify css transform functions
39- - evaluate math functions: calc(), clamp(), min(), max(), etc.
40- - inline css variables
41- - remove duplicate properties
42- - flatten @import rules
33+ - color conversion to any supported color format
34+ - automatic nested css rules generation
35+ - nested css rules conversion to legacy syntax
36+ - sourcemap generation
37+ - css shorthands computation . see the supported properties list below
38+ - css transform functions minification
39+ - css math functions evaluation : calc(), clamp(), min(), max(), etc.
40+ - css variables inlining
41+ - duplicate properties removal
42+ - @import rules flattening
4343- experimental CSS prefix removal
4444
4545## Online documentation
@@ -54,7 +54,7 @@ Try it [online](https://tbela99.github.io/css-parser/playground/)
5454
5555There are several ways to import the library into your application.
5656
57- ### Node exports
57+ ### Node
5858
5959import as a module
6060
@@ -65,7 +65,7 @@ import {transform} from '@tbela99/css-parser';
6565// ...
6666```
6767
68- ### Deno exports
68+ ### Deno
6969
7070import as a module
7171
@@ -85,7 +85,7 @@ const {transform} = require('@tbela99/css-parser/cjs');
8585// ...
8686```
8787
88- ### Web export
88+ ### Web
8989
9090Programmatic import
9191
@@ -163,19 +163,27 @@ Javascript umd module from cdn
163163 </script >
164164```
165165
166- ## Transform
166+ ## Exported functions
167167
168- Parse and render css in a single pass.
168+ ``` ts
169169
170- ### Usage
171-
172- ``` typescript
170+ /* parse and render css */
171+ transform (css : string | ReadableStream < string > , options ?: TransformOptions = {}): Promise < TransformResult >
172+ /* parse css */
173+ parse (css : string | ReadableStream < string > , options ?: ParseOptions = {}): Promise < ParseResult > ;
174+ /* render ast */
175+ render (ast : AstNode , options ?: RenderOptions = {}): RenderResult ;
176+ /* parse and render css file or url */
177+ transformFile (filePathOrUrl : string , options ?: TransformOptions = {}, asStream ?: boolean ): Promise < TransformResult > ;
178+ /* parse css file or url */
179+ parseFile (filePathOrUrl : string , options ?: ParseOptions = {}, asStream ?: boolean ): Promise < ParseResult > ;
173180
174- transform (css : string | ReadableStream < string > , transformOptions : TransformOptions = {}): TransformResult
175- parse (css : string | ReadableStream < string > , parseOptions : ParseOptions = {}): ParseResult ;
176- render (ast : AstNode , renderOptions : RenderOptions = {}): RenderResult ;
177181```
178182
183+ ## Transform
184+
185+ Parse and render css in a single pass.
186+
179187### Example
180188
181189``` javascript
@@ -209,7 +217,7 @@ Include ParseOptions and RenderOptions
209217> Minify Options
210218
211219- minify: boolean, optional. default to _ true_ . optimize ast.
212- - pass: number, optional. minification pass . default to 1
220+ - pass: number, optional. minification passes . default to 1
213221- nestingRules: boolean, optional. automatically generated nested rules.
214222- expandNestingRules: boolean, optional. convert nesting rules into separate rules. will automatically set nestingRules
215223 to false.
@@ -900,7 +908,7 @@ for (const {node, parent, root} of walk(ast)) {
900908
901909Ast can be transformed using node visitors
902910
903- ### Exemple 1: Declaration
911+ ### Example 1: Declaration
904912
905913the visitor is called for any declaration encountered
906914
@@ -935,7 +943,7 @@ console.debug(result.code);
935943// .foo{transform:scale(calc(40/3))}
936944```
937945
938- ### Exemple 2: Declaration
946+ ### Example 2: Declaration
939947
940948the visitor is called only on 'height' declarations
941949
@@ -990,7 +998,7 @@ console.debug(result.code);
990998
991999```
9921000
993- ### Exemple 3: At-Rule
1001+ ### Example 3: At-Rule
9941002
9951003the visitor is called on any at-rule
9961004
@@ -1032,7 +1040,7 @@ console.debug(result.code);
10321040
10331041```
10341042
1035- ### Exemple 4: At-Rule
1043+ ### Example 4: At-Rule
10361044
10371045the visitor is called only for at-rule media
10381046
@@ -1074,7 +1082,7 @@ console.debug(result.code);
10741082
10751083```
10761084
1077- ### Exemple 5: Rule
1085+ ### Example 5: Rule
10781086
10791087the visitor is called on any Rule
10801088
@@ -1110,7 +1118,7 @@ console.debug(result.code);
11101118
11111119```
11121120
1113- ### Exemple 6: Rule
1121+ ### Example 6: Rule
11141122
11151123Adding declarations to any rule
11161124
0 commit comments