File tree Expand file tree Collapse file tree 5 files changed +39
-5
lines changed Expand file tree Collapse file tree 5 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,13 @@ type MathParenthesizedExpression struct {
96
96
Value Value
97
97
}
98
98
99
+ // Raw is an otherwise non-structured but valid value.
100
+ type Raw struct {
101
+ Span
102
+
103
+ Value string
104
+ }
105
+
99
106
// Comma is a single comma. Some declarations require commas,
100
107
// e.g. font-family fallbacks or transitions.
101
108
type Comma struct {
@@ -110,6 +117,7 @@ func (MathParenthesizedExpression) isValue() {}
110
117
func (Comma ) isValue () {}
111
118
func (Identifier ) isValue () {}
112
119
func (HexColor ) isValue () {}
120
+ func (Raw ) isValue () {}
113
121
114
122
var _ Value = String {}
115
123
var _ Value = Dimension {}
@@ -119,3 +127,4 @@ var _ Value = MathParenthesizedExpression{}
119
127
var _ Value = Comma {}
120
128
var _ Value = Identifier {}
121
129
var _ Value = HexColor {}
130
+ var _ Value = Raw {}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ func TestIntegration(t *testing.T) {
16
16
"testdata/comments.css" ,
17
17
"testdata/bem.css" ,
18
18
"testdata/font-face.css" ,
19
+ "testdata/grid.css" ,
19
20
} {
20
21
t .Run (c , func (t * testing.T ) {
21
22
Original file line number Diff line number Diff line change @@ -141,9 +141,15 @@ func (p *parser) parseDeclarationBlock() *ast.DeclarationBlock {
141
141
case lexer .EOF :
142
142
p .lexer .Errorf ("unexpected EOF" )
143
143
144
+ case lexer .Comma :
145
+ decl .Values = append (decl .Values , & ast.Comma {Span : p .lexer .TokenSpan ()})
146
+ p .lexer .Next ()
147
+
144
148
case lexer .Delim :
145
149
if p .lexer .CurrentString != "!" {
146
- p .lexer .Errorf ("unexpected token: %s" , p .lexer .CurrentString )
150
+ decl .Values = append (decl .Values , & ast.Raw {Span : p .lexer .TokenSpan (), Value : p .lexer .CurrentString })
151
+ p .lexer .Next ()
152
+ continue
147
153
}
148
154
p .lexer .Next ()
149
155
@@ -154,10 +160,6 @@ func (p *parser) parseDeclarationBlock() *ast.DeclarationBlock {
154
160
p .lexer .Next ()
155
161
decl .Important = true
156
162
157
- case lexer .Comma :
158
- decl .Values = append (decl .Values , & ast.Comma {Span : p .lexer .TokenSpan ()})
159
- p .lexer .Next ()
160
-
161
163
default :
162
164
val := p .parseValue ()
163
165
if val == nil {
Original file line number Diff line number Diff line change @@ -363,6 +363,9 @@ func (p *printer) print(in ast.Node) {
363
363
}
364
364
p .s .WriteRune (')' )
365
365
366
+ case * ast.Raw :
367
+ p .s .WriteString (node .Value )
368
+
366
369
default :
367
370
panic (fmt .Sprintf ("unknown ast node: %s" , reflect .TypeOf (in ).String ()))
368
371
}
Original file line number Diff line number Diff line change
1
+ .a {
2
+ grid-column : 1 / span 2 ;
3
+ grid-template : "text" auto "meter" 1fr / 1fr ;
4
+ }
5
+
6
+ .b {
7
+ grid-column : 3 ;
8
+ grid-row : 1 / span 2 ;
9
+ }
10
+
11
+ .c {
12
+ grid-column : 1 ;
13
+ grid-row : 2 ;
14
+ }
15
+
16
+ .d {
17
+ grid-column : 2 ;
18
+ grid-row : 2 ;
19
+ }
You can’t perform that action at this time.
0 commit comments