mirror of
https://github.com/thangisme/notes.git
synced 2024-11-05 12:57:15 -05:00
42 lines
3.8 KiB
JavaScript
42 lines
3.8 KiB
JavaScript
'use strict';
|
|
|
|
exports.__esModule = true;
|
|
exports.default = parse;
|
|
|
|
var _parser = require('./parser');
|
|
|
|
var _parser2 = _interopRequireDefault(_parser);
|
|
|
|
var _input = require('./input');
|
|
|
|
var _input2 = _interopRequireDefault(_input);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function parse(css, opts) {
|
|
if (opts && opts.safe) {
|
|
throw new Error('Option safe was removed. ' + 'Use parser: require("postcss-safe-parser")');
|
|
}
|
|
|
|
var input = new _input2.default(css, opts);
|
|
|
|
var parser = new _parser2.default(input);
|
|
try {
|
|
parser.tokenize();
|
|
parser.loop();
|
|
} catch (e) {
|
|
if (e.name === 'CssSyntaxError' && opts && opts.from) {
|
|
if (/\.scss$/i.test(opts.from)) {
|
|
e.message += '\nYou tried to parse SCSS with ' + 'the standard CSS parser; ' + 'try again with the postcss-scss parser';
|
|
} else if (/\.less$/i.test(opts.from)) {
|
|
e.message += '\nYou tried to parse Less with ' + 'the standard CSS parser; ' + 'try again with the postcss-less parser';
|
|
}
|
|
}
|
|
throw e;
|
|
}
|
|
|
|
return parser.root;
|
|
}
|
|
module.exports = exports['default'];
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBhcnNlLmVzNiJdLCJuYW1lcyI6WyJwYXJzZSIsImNzcyIsIm9wdHMiLCJzYWZlIiwiRXJyb3IiLCJpbnB1dCIsInBhcnNlciIsInRva2VuaXplIiwibG9vcCIsImUiLCJuYW1lIiwiZnJvbSIsInRlc3QiLCJtZXNzYWdlIiwicm9vdCJdLCJtYXBwaW5ncyI6Ijs7O2tCQUd3QkEsSzs7QUFIeEI7Ozs7QUFDQTs7Ozs7O0FBRWUsU0FBU0EsS0FBVCxDQUFlQyxHQUFm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zIHBhcnNlcic7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhyb3cgZTtcbiAgICB9XG5cbiAgICByZXR1cm4gcGFyc2VyLnJvb3Q7XG59XG4iXX0=
|