https://github.com/nuintun/style-tokens
A tools can parse css text to css tokens
https://github.com/nuintun/style-tokens
Last synced: about 1 year ago
JSON representation
A tools can parse css text to css tokens
- Host: GitHub
- URL: https://github.com/nuintun/style-tokens
- Owner: nuintun
- License: mit
- Created: 2014-04-24T14:07:52.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-04-21T02:09:46.000Z (about 9 years ago)
- Last Synced: 2024-09-14T16:23:16.132Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://nuintun.github.io/style-tokens
- Size: 460 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# style-tokens
>A tools can parse css text to css tokens
>
>[![NPM Version][npm-image]][npm-url]
>[![Download Status][download-image]][npm-url]
>[![Travis Status][travis-image]][travis-url]
>[![Test Coverage][coveralls-image]][coveralls-url]
>[![Dependencies][david-image]][david-url]
### Reference :
>Modify from csso: [https://github.com/css/csso](https://github.com/css/csso)
### Install
```
$ npm install style-tokens
```
### Introduction:
>Use:
```js
var tokens,
Tokens = require('style-tokens'),
csstext = '/* base.css */body { color: red; }';
tokens = Tokens.Parse(csstext); // parse css
console.log(Tokens.TokenType); // all tokens's type, the value is readonly
console.log(tokens);
```
>Tokens output:
```js
[
{
"index": 0,
"type": "CommentML",
"value": "/* base.css */",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 14
}
},
{
"index": 1,
"type": "Identifier",
"value": "body",
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 18
}
},
{
"index": 2,
"type": "Space",
"value": " ",
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 19
}
},
{
"index": 3,
"type": "LeftCurlyBracket",
"value": "{",
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 20
},
"right": 11
},
{
"index": 4,
"type": "Space",
"value": " ",
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 21
}
},
{
"index": 5,
"type": "Identifier",
"value": "color",
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 26
}
},
{
"index": 6,
"type": "Colon",
"value": ":",
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 27
}
},
{
"index": 7,
"type": "Space",
"value": " ",
"start": {
"line": 1,
"column": 28
},
"end": {
"line": 1,
"column": 28
}
},
{
"index": 8,
"type": "Identifier",
"value": "red",
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 31
}
},
{
"index": 9,
"type": "Semicolon",
"value": ";",
"start": {
"line": 1,
"column": 32
},
"end": {
"line": 1,
"column": 32
}
},
{
"index": 10,
"type": "Space",
"value": " ",
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 33
}
},
{
"index": 11,
"type": "RightCurlyBracket",
"value": "}",
"start": {
"line": 1,
"column": 34
},
"end": {
"line": 1,
"column": 34
},
"left": 3
}
]
```
[travis-image]: http://img.shields.io/travis/nuintun/style-tokens.svg?style=flat-square
[travis-url]: https://travis-ci.org/nuintun/style-tokens
[coveralls-image]: http://img.shields.io/coveralls/nuintun/style-tokens/master.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/nuintun/style-tokens?branch=master
[david-image]: http://img.shields.io/david/nuintun/style-tokens.svg?style=flat-square
[david-url]: https://david-dm.org/nuintun/style-tokens
[npm-image]: http://img.shields.io/npm/v/style-tokens.svg?style=flat-square
[npm-url]: https://www.npmjs.org/package/style-tokens
[download-image]: http://img.shields.io/npm/dm/style-tokens.svg?style=flat-square