Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | 'use strict'
|
---|
2 |
|
---|
3 | let Container = require('./container')
|
---|
4 | let Parser = require('./parser')
|
---|
5 | let Input = require('./input')
|
---|
6 |
|
---|
7 | function parse(css, opts) {
|
---|
8 | let input = new Input(css, opts)
|
---|
9 | let parser = new Parser(input)
|
---|
10 | try {
|
---|
11 | parser.parse()
|
---|
12 | } catch (e) {
|
---|
13 | if (process.env.NODE_ENV !== 'production') {
|
---|
14 | if (e.name === 'CssSyntaxError' && opts && opts.from) {
|
---|
15 | if (/\.scss$/i.test(opts.from)) {
|
---|
16 | e.message +=
|
---|
17 | '\nYou tried to parse SCSS with ' +
|
---|
18 | 'the standard CSS parser; ' +
|
---|
19 | 'try again with the postcss-scss parser'
|
---|
20 | } else if (/\.sass/i.test(opts.from)) {
|
---|
21 | e.message +=
|
---|
22 | '\nYou tried to parse Sass with ' +
|
---|
23 | 'the standard CSS parser; ' +
|
---|
24 | 'try again with the postcss-sass parser'
|
---|
25 | } else if (/\.less$/i.test(opts.from)) {
|
---|
26 | e.message +=
|
---|
27 | '\nYou tried to parse Less with ' +
|
---|
28 | 'the standard CSS parser; ' +
|
---|
29 | 'try again with the postcss-less parser'
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
33 | throw e
|
---|
34 | }
|
---|
35 |
|
---|
36 | return parser.root
|
---|
37 | }
|
---|
38 |
|
---|
39 | module.exports = parse
|
---|
40 | parse.default = parse
|
---|
41 |
|
---|
42 | Container.registerParse(parse)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.