Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## v1.3.4

- [x] make streaming optional #109
- [x] patch at-rule syntax for @font-feature-value #110
- [x] support percentage in transform() and scale() #111
- [x] allow arrays in visitor definition #112

## v1.3.3

- [x] relative color computation bug #105
Expand Down
37 changes: 20 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# css-parser

CSS parser and minifier for node and the browser
CSS parser, minifier and validator for node and the browser

## Installation

Expand Down Expand Up @@ -101,7 +101,7 @@ Javascript module from cdn

<script type="module">

import {transform} from 'https://esm.sh/@tbela99/css-parser@1.3.3/web';
import {transform} from 'https://esm.sh/@tbela99/css-parser@1.3.4/web';

const css = `
.s {
Expand All @@ -126,7 +126,7 @@ Javascript umd module from cdn

```html

<script src="https://unpkg.com/@tbela99/css-parser@1.3.2/dist/index-umd-web.js"></script>
<script src="https://unpkg.com/@tbela99/css-parser@1.3.4/dist/index-umd-web.js"></script>
<script>

(async () => {
Expand Down Expand Up @@ -764,6 +764,7 @@ result
# Node Walker

```javascript

import {walk} from '@tbela99/css-parser';

for (const {node, parent, root} of walk(ast)) {
Expand Down Expand Up @@ -923,7 +924,8 @@ const css = `
}
`;

console.debug(await transform(css, options));
const result = await transform(css, options);
console.debug(result.code);

// .foo{transform:scale(calc(40/3))}
```
Expand All @@ -934,9 +936,7 @@ the visitor is called only on 'height' declarations

```typescript

import {AstDeclaration, LengthToken, ParserOptions} from "../src/@types";
import {EnumToken} from "../src/lib";
import {transform} from "../src/node";
import {AstDeclaration, EnumToken, LengthToken, ParserOptions, transform} from '@tbela99/css-parser';

const options: ParserOptions = {

Expand Down Expand Up @@ -978,7 +978,8 @@ color: lch(from peru calc(l * 0.8) calc(c * 0.7) calc(h + 180))
}
`;

console.debug(await transform(css, options));
const result = await transform(css, options);
console.debug(result.code);

// .foo{height:calc(40px/3);width:3px}.selector{color:#0880b0}

Expand Down Expand Up @@ -1019,7 +1020,8 @@ const css = `
}
`;

console.debug(await transform(css, options));
const result = await transform(css, options);
console.debug(result.code);

// .foo{height:calc(40px/3)}

Expand Down Expand Up @@ -1060,7 +1062,8 @@ const css = `
}
`;

console.debug(await transform(css, options));
const result = await transform(css, options);
console.debug(result.code);

// .foo{height:calc(40px/3)}

Expand All @@ -1079,10 +1082,10 @@ const options: ParserOptions = {

visitor: {


Rule(node: AstRule): AstRule {

return {...node, sel: '.foo,.bar,.fubar'};
node.sel = '.foo,.bar,.fubar'
return node;
}
}
};
Expand All @@ -1095,7 +1098,8 @@ const css = `
}
`;

console.debug(await transform(css, options));
const result = await transform(css, options);
console.debug(result.code);

// .foo,.bar,.fubar{height:calc(40px/3)}

Expand All @@ -1107,9 +1111,7 @@ Adding declarations to any rule

```typescript

import {transform} from "../src/node";
import {AstRule, ParserOptions} from "../src/@types";
import {parseDeclarations} from "../src/lib";
import {AstRule, parseDeclarations, ParserOptions, transform} from '@tbela99/css-parser';

const options: ParserOptions = {

Expand All @@ -1135,7 +1137,8 @@ const css = `
}
`;

console.debug(await transform(css, options));
const result = await transform(css, options);
console.debug(result.code);

// .foo{width:3px}

Expand Down
Loading