Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions lib/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright © 2018 Andrew Powell

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of this Source Code Form.
*/
import Input from 'postcss/lib/input';

import Parser from './ValuesParser';
import Stringifier from './ValuesStringifier';

// TODO: walk methods for custom nodes

export function parse(css, options) {
const input = new Input(css, options);
const parser = new Parser(input, options);

parser.parse();

return parser.root;
};

export function stringify(node, builder) {
const stringifier = new Stringifier(builder);
stringifier.stringify(node);
};

export function nodeToString(node) {
let result = '';

stringify(node, (bit) => {
result += bit;
});

return result;
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"homepage": "https://github.com/shellscape/postcss-values-parser",
"bugs": "https://github.com/shellscape/postcss-values-parser/issues",
"main": "lib/index.js",
"module": "lib/index.mjs",
"engines": {
"node": ">=6.14.4"
},
Expand Down