Comments (4)
Lots of the parsing code and most of the AST documentation is about the myriad of different at-rules. I’d suggest we’d parse them like this instead:
- type:
'at-rule'
- name:
String
. The part directly after the@
, such as “media”, “viewport”, “charset”, “whatever”. - value:
String
. The part that comes after the name, and before the;
or{
. This string may be empty. - declarations:
Array
of nodes with the typesdeclaration
andcomment
, or null. If the at-rule has a block, and that block can be parsed as declarations this property represents those declarations. Otherwise it isnull
.@page
is an example. - rules:
Array
of nodes with the typesrule
,at-rule
andcomment
, or null. If the at-rule has a block, and that block can be parsed as rules this property represents those rules. Otherwise it isnull
.@media
is an example.
All at-rules have .value
. Some have .declarations
. Some have .rules
. Some have neither (such as @charset
), but none have both.
Pros:
- Future at-rules automatically supported.
- Simpler code.
- Less properties to know about in the AST: no more
.media
,.document
,.charset
, etc.—just.value
! - Less documentation to read.
- Consistent with the rest of the parsing: Only parse syntax, not semantics.
This would be for css 3.0.
from css.
Yeah that sounds good.
from css.
from css.
+1
We have the same issue when parsin third party css (AlloyUI)
@-ms-viewport {
.wrapper {
width: device-width; } }
@-ms-keyframes progress-bar-stripes {
.aui from {
background-position: 40px 0; }
.aui to {
background-position: 0 0; } }
Is causing error: missing '}'
from css.
Related Issues (20)
- when comments include a "{" parse error
- Nested at-rules stringified with incorrectly (indentation-wise)
- @import rule parsing breaks if the argument of `url` contains a semi-colon (e.g. Nunito Google font)
- Files without css not included in sourcemaps
- Can't resolve 'fs' in '.\node_modules\css\lib\stringify' when building HOT 9
- AST Explorer is broken HOT 1
- Hi is there any type definitions for this library ?
- " and &apos are not recognized
- undefined:2:1230: property missing ':' when using background with Data URI HOT 5
- Parsing of URL fields
- Trying to get in touch regarding a security issue HOT 4
- Declaration parsing fails with this mess of quotes, brackets & braces HOT 1
- Duplicate packages detected in the css project on Tag: v3.0.0
- Comments in a string are lost
- Mycss HOT 2
- [email protected] dependency is deprecated HOT 12
- Typescript support, performance optimization and browser friendly version (no source-map) HOT 6
- @layer is not supported with css v3 HOT 1
- Fork to continue work: https://github.com/node-projects/css-parser HOT 1
- @container support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from css.