Skip to content

Commit d903f57

Browse files
committed
Put the CSSGrammar into the readme as an example.
1 parent 5bd2f43 commit d903f57

File tree

1 file changed

+60
-24
lines changed

1 file changed

+60
-24
lines changed

README.md

+60-24
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,29 @@ rendering the result into an easier-to-digest form.
8282

8383
A grammar is an object with one of the following four forms:
8484

85-
1.
86-
```
87-
{"stylesheet":true}
88-
```
89-
90-
2.
91-
```
92-
{
93-
"qualified": <grammar>,
94-
"@foo": <grammar>,
95-
"unknown": <function>
96-
}
97-
```
98-
99-
3.
100-
```
101-
{
102-
"declarations": true,
103-
"@foo": <grammar>
104-
"unknown": <function>
105-
}
106-
```
107-
108-
4. `null`
85+
```js
86+
{"stylesheet":true}
87+
```
88+
89+
```js
90+
{
91+
"qualified": <grammar>,
92+
"@foo": <grammar>,
93+
"unknown": <function>
94+
}
95+
```
96+
97+
```js
98+
{
99+
"declarations": true,
100+
"@foo": <grammar>
101+
"unknown": <function>
102+
}
103+
```
104+
105+
```js
106+
null
107+
```
109108

110109
A `stylesheet` block contains nothing else;
111110
it just means that this rule uses the top-level grammar for its contents.
@@ -135,6 +134,43 @@ like `@import`.
135134
A `CSSGrammar` object is provided with a default grammar for CSS.
136135
If you call `canonicalize()` without a grammar,
137136
this is used automatically.
137+
This is what it currently looks like:
138+
139+
```js
140+
var CSSGrammar = {
141+
qualified: {declarations:true},
142+
"@media": {stylesheet:true},
143+
"@keyframes": {qualified:{declarations:true}},
144+
"@font-face": {declarations:true},
145+
"@supports": {stylesheet:true},
146+
"@scope": {stylesheet:true},
147+
"@counter-style": {declarations:true},
148+
"@import": null,
149+
"@font-feature-values": {declarations:true},
150+
"@viewport": {declarations:true},
151+
"@page": {
152+
declarations: true,
153+
"@top-left-corner": {declarations:true},
154+
"@top-left": {declarations:true},
155+
"@top-center": {declarations:true},
156+
"@top-right": {declarations:true},
157+
"@top-right-corner": {declarations:true},
158+
"@right-top": {declarations:true},
159+
"@right-middle": {declarations:true},
160+
"@right-bottom": {declarations:true},
161+
"@right-bottom-corner": {declarations:true},
162+
"@bottom-right": {declarations:true},
163+
"@bottom-center": {declarations:true},
164+
"@bottom-left": {declarations:true},
165+
"@bottom-left-corner": {declarations:true},
166+
"@left-bottom": {declarations:true},
167+
"@left-center": {declarations:true},
168+
"@left-top": {declarations:true},
169+
},
170+
"@custom-selector": null,
171+
"@custom-media": null
172+
}
173+
```
138174
139175
The return value is a nested structure of objects.
140176
Each has a "type" key, set to either "stylesheet", "qualified-rule" or "at-rule".

0 commit comments

Comments
 (0)