2.1.8 • Published 1 year ago

@emmetio/css-abbreviation v2.1.8

Weekly downloads
6,888
License
MIT
Repository
github
Last release
1 year ago

Emmet stylesheet abbreviation parser

Parses given Emmet stylesheet abbreviation into AST. Parsing is performed in two steps: first it tokenizes given abbreviation (useful for syntax highlighting in editors) and then tokens are analyzed and converted into AST nodes as plain, JSON-serializable objects.

Unlike in markup abbreviations, elements in stylesheet abbreviations cannot be nested and contain attributes, but allow embedded values in element names.

Usage

You can install it via npm:

npm install @emmetio/css-abbreviation

Then add it into your project:

import parse from '@emmetio/css-abbreviation';

const props = parse('p10+poa');
/* [{
    name: 'p',
    value: [{ type: 'CSSValue', value: [...] }],
    important: false
}, {
    name: 'poa',
    value: [],
    important: false
}] */

The returned result is an array of CSSProperty items: a node with name and values.

Abbreviation syntax

Emmet stylesheet abbreviation element may start with name and followed by values, optionally chained with - delimiter. In most cases, actual CSS properties doesn’t have numbers in their names (or at least they are not used in abbreviation shortcuts) so a number right after alpha characters is considered as embedded value, as well as colors starting with # character: p10, bg#fc0 etc. If implicit name/value boundary can’t be identified, you should use - as value separator: m-a, p10-20 etc.

Operators

Since CSS properties can’t be nested, the only available operator is +.

2.1.6

1 year ago

2.1.5

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.4

3 years ago

2.1.3

3 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

2.0.0-rc.7

4 years ago

2.0.0-rc.8

4 years ago

2.0.0-rc.6

4 years ago

2.0.0-rc.5

4 years ago

2.0.0-rc.3

4 years ago

2.0.0-rc.4

4 years ago

2.0.0-rc.2

5 years ago

2.0.0-rc.1

5 years ago

2.0.0-rc.0

5 years ago

0.4.0

6 years ago

0.3.2

6 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago