1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | const Input = require('postcss/lib/input');
|
12 |
|
13 | const Parser = require('./ValuesParser');
|
14 | const { stringify } = require('./ValuesStringifier');
|
15 |
|
16 | module.exports = {
|
17 | parse(css, options) {
|
18 | const input = new Input(css, options);
|
19 | const parser = new Parser(input, options);
|
20 |
|
21 | parser.parse();
|
22 |
|
23 | const { root } = parser;
|
24 | const ogToString = root.toString;
|
25 |
|
26 | function toString(stringifier) {
|
27 | return ogToString.bind(root)(stringifier || module.exports.stringify);
|
28 | }
|
29 |
|
30 | root.toString = toString.bind(root);
|
31 |
|
32 | return parser.root;
|
33 | },
|
34 |
|
35 | stringify,
|
36 |
|
37 | nodeToString(node) {
|
38 | let result = '';
|
39 |
|
40 | module.exports.stringify(node, (bit) => {
|
41 | result += bit;
|
42 | });
|
43 |
|
44 | return result;
|
45 | }
|
46 | };
|