@il4mb/css-tokenizer 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +2 -23
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -19,27 +19,7 @@ const content = "width: 10px";
|
|
|
19
19
|
const result = tokenizeImpl(content);
|
|
20
20
|
|
|
21
21
|
// Tuple list entries are [type, start, end]
|
|
22
|
-
console.log(result
|
|
23
|
-
|
|
24
|
-
// Convert tuples to a structured token tree (useful for walking semantic tokens)
|
|
25
|
-
console.log(JSON.stringify(result.toTokenTree(content), null, 2));
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Example token tree (for the value `10px`):
|
|
29
|
-
|
|
30
|
-
```json
|
|
31
|
-
[
|
|
32
|
-
{
|
|
33
|
-
"type": "dimension",
|
|
34
|
-
"start": 7,
|
|
35
|
-
"end": 11,
|
|
36
|
-
"value": "10px",
|
|
37
|
-
"children": [
|
|
38
|
-
{ "type": "number", "start": 7, "end": 9, "value": "10" },
|
|
39
|
-
{ "type": "word", "start": 9, "end": 11, "value": "px" }
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
]
|
|
22
|
+
console.log(result);
|
|
43
23
|
```
|
|
44
24
|
|
|
45
25
|
## Custom token types
|
|
@@ -67,8 +47,7 @@ const tokenizer = new Tokenizer(registry);
|
|
|
67
47
|
const content = `--primary`;
|
|
68
48
|
const result = tokenizer.tokenize(content);
|
|
69
49
|
|
|
70
|
-
console.log(result
|
|
71
|
-
console.log(JSON.stringify(result.toTokenTree(content), null, 2));
|
|
50
|
+
console.log(result);
|
|
72
51
|
```
|
|
73
52
|
|
|
74
53
|
## API (high level)
|