less 1.0.15 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.15
1
+ 1.0.16
data/less.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{less}
5
- s.version = "1.0.15"
5
+ s.version = "1.0.16"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["cloudhead"]
9
- s.date = %q{2009-07-21}
9
+ s.date = %q{2009-07-23}
10
10
  s.default_executable = %q{lessc}
11
11
  s.description = %q{LESS is leaner CSS}
12
12
  s.email = %q{self@cloudhead.net}
@@ -140,6 +140,7 @@ Gem::Specification.new do |s|
140
140
  "spec/css/mixins-args.css",
141
141
  "spec/css/mixins.css",
142
142
  "spec/css/operations.css",
143
+ "spec/css/parens.css",
143
144
  "spec/css/rulesets.css",
144
145
  "spec/css/scope.css",
145
146
  "spec/css/selectors.css",
@@ -166,6 +167,7 @@ Gem::Specification.new do |s|
166
167
  "spec/less/mixins-args.less",
167
168
  "spec/less/mixins.less",
168
169
  "spec/less/operations.less",
170
+ "spec/less/parens.less",
169
171
  "spec/less/rulesets.less",
170
172
  "spec/less/scope.less",
171
173
  "spec/less/selectors.less",
data/lib/less.rb CHANGED
@@ -67,6 +67,21 @@ class Object
67
67
  def error!(s) raise Exception, s end
68
68
  end
69
69
 
70
+ class Array
71
+ def dissolve
72
+ ary = flatten.compact
73
+ case ary.size
74
+ when 0 then []
75
+ when 1 then first
76
+ else ary
77
+ end
78
+ end
79
+
80
+ def one?
81
+ size == 1
82
+ end
83
+ end
84
+
70
85
  class Class
71
86
  def to_sym
72
87
  self.to_s.to_sym
data/lib/less/command.rb CHANGED
@@ -53,7 +53,7 @@ module Less
53
53
  def parse new = false
54
54
  begin
55
55
  # Create a new Less object with the contents of a file
56
- css = Less::Engine.new(File.new @source).to_css
56
+ css = Less::Engine.new(File.new(@source)).to_css
57
57
  css = css.delete " \n" if compress?
58
58
 
59
59
  File.open( @destination, "w" ) do |file|
data/lib/less/engine.rb CHANGED
@@ -15,7 +15,7 @@ module Less
15
15
 
16
16
  def initialize obj
17
17
  @less = if obj.is_a? File
18
- @path = File.dirname(File.expand_path obj.path)
18
+ @path = File.dirname File.expand_path(obj.path)
19
19
  obj.read
20
20
  elsif obj.is_a? String
21
21
  obj.dup
@@ -36,7 +36,7 @@ grammar Less
36
36
  path = File.join(env.root.file, url.value)
37
37
  path += '.less' unless path =~ /\.(le|c)ss$/
38
38
  if File.exist? path
39
- imported = Less::Engine.new(File.new path).to_tree
39
+ imported = Less::Engine.new(File.new(path)).to_tree
40
40
  env.rules += imported.rules
41
41
  else
42
42
  raise ImportError, path
@@ -48,7 +48,7 @@ grammar Less
48
48
  rule url
49
49
  'url(' path:(string / [-a-zA-Z0-9_%$/.&=:;#+?]+) ')' {
50
50
  def build env = nil
51
- Node::String.new(CGI.unescape path.text_value)
51
+ Node::String.new CGI.unescape(path.text_value)
52
52
  end
53
53
 
54
54
  def value
@@ -100,20 +100,47 @@ grammar Less
100
100
  # height: 100%;
101
101
  #
102
102
  rule declaration
103
- ws name:(ident / variable) s ':' s expression s (';'/ ws &'}') ws {
103
+ ws name:(ident / variable) s ':' s expressions s (';'/ ws &'}') ws {
104
104
  def build env
105
- env << (name.text_value =~ /^@/ ? Node::Variable : Node::Property).new(name.text_value, [])
106
- expression.build env
105
+ env << (name.text_value =~ /^@/ ?
106
+ Node::Variable : Node::Property).new(name.text_value, expressions.build(env), env)
107
+
107
108
  end
108
109
  # Empty rule
109
110
  } / ws ident s ':' s ';' ws
110
111
  end
111
112
 
113
+ rule expressions
114
+ expression+ {
115
+ def build env
116
+ elements.map do |e|
117
+ e.build(env) if e.respond_to? :build
118
+ end.compact
119
+ end
120
+ }
121
+ end
122
+
112
123
  #
113
124
  # An operation or compound value
114
125
  #
115
126
  rule expression
116
- entity (operator / S / WS) expression <Builder> / entity
127
+ s '(' s expressions s ')' s {
128
+ def build env
129
+ Node::Expression.new(['('] + expressions.build(env).flatten + [')'])
130
+ end
131
+ } / entity tail:(operator entity)* ws {
132
+ def build env
133
+ exp = all.map do |e|
134
+ e.method(:build).arity.zero??
135
+ e.build : e.build(env) if e.respond_to? :build
136
+ end.dissolve
137
+ exp.is_a?(Array) ? Node::Expression.new(exp) : exp
138
+ end
139
+
140
+ def all
141
+ [entity] + tail.elements.map {|i| [i.operator, i.entity] }.flatten.compact
142
+ end
143
+ }
117
144
  end
118
145
 
119
146
  #
@@ -125,22 +152,23 @@ grammar Less
125
152
 
126
153
  rule fonts
127
154
  font family:(s ',' s font)+ {
128
- def build env
129
- fonts = ([font] + family.elements.map {|f| f.font }).map do |font|
130
- font.build env
131
- end
132
- env.identifiers.last << Node::FontFamily.new(fonts)
155
+ def build
156
+ Node::FontFamily.new(all.map(&:build))
157
+ end
158
+
159
+ def all
160
+ [font] + family.elements.map {|f| f.font }
133
161
  end
134
162
  }
135
163
  end
136
164
 
137
165
  rule font
138
166
  [a-zA-Z] [-a-zA-Z0-9]* {
139
- def build env
167
+ def build
140
168
  Node::Keyword.new(text_value)
141
169
  end
142
170
  } / string {
143
- def build env
171
+ def build
144
172
  Node::String.new(text_value)
145
173
  end
146
174
  }
@@ -155,8 +183,8 @@ grammar Less
155
183
 
156
184
  rule variable
157
185
  '@' [-a-zA-Z0-9_]+ {
158
- def build env
159
- env.identifiers.last << Node::Variable.new(text_value)
186
+ def build
187
+ Node::Variable.new(text_value)
160
188
  end
161
189
  }
162
190
  end
@@ -199,19 +227,19 @@ grammar Less
199
227
  rule accessor
200
228
  ident:(class_id / tag) '[' attr:(string / variable) ']' {
201
229
  def build env
202
- env.identifiers.last << env.nearest(ident.text_value)[attr.text_value.delete(%q["'])].evaluate
230
+ env.nearest(ident.text_value)[attr.text_value.delete(%q["'])].evaluate
203
231
  end
204
232
  }
205
233
  end
206
234
 
207
235
  rule operator
208
236
  S [-+*/] S {
209
- def build env
210
- env.identifiers.last << Node::Operator.new(text_value.strip)
237
+ def build
238
+ Node::Operator.new(text_value.strip)
211
239
  end
212
240
  } / [-+*/] {
213
- def build env
214
- env.identifiers.last << Node::Operator.new(text_value)
241
+ def build
242
+ Node::Operator.new(text_value)
215
243
  end
216
244
  }
217
245
  end
@@ -221,16 +249,16 @@ grammar Less
221
249
  #
222
250
  rule literal
223
251
  color / (dimension / [-a-z]+) '/' dimension {
224
- def build env
225
- env.identifiers.last << Node::Anonymous.new(text_value)
252
+ def build
253
+ Node::Anonymous.new(text_value)
226
254
  end
227
255
  } / number unit {
228
- def build env
229
- env.identifiers.last << Node::Number.new(number.text_value, unit.text_value)
256
+ def build
257
+ Node::Number.new(number.text_value, unit.text_value)
230
258
  end
231
259
  } / string {
232
- def build env
233
- env.identifiers.last << Node::String.new(text_value)
260
+ def build
261
+ Node::String.new(text_value)
234
262
  end
235
263
  }
236
264
  end
@@ -238,8 +266,8 @@ grammar Less
238
266
  # !important
239
267
  rule important
240
268
  '!important' {
241
- def build env
242
- env.identifiers.last << Node::Keyword.new(text_value)
269
+ def build
270
+ Node::Keyword.new(text_value)
243
271
  end
244
272
  }
245
273
  end
@@ -249,8 +277,8 @@ grammar Less
249
277
  #
250
278
  rule keyword
251
279
  [-a-zA-Z]+ !ns {
252
- def build env
253
- env.identifiers.last << Node::Keyword.new(text_value)
280
+ def build
281
+ Node::Keyword.new(text_value)
254
282
  end
255
283
  }
256
284
  end
@@ -261,11 +289,11 @@ grammar Less
261
289
  rule string
262
290
  "'" content:(!"'" . )* "'" {
263
291
  def value
264
- text_value[1...-1]
292
+ content.text_value
265
293
  end
266
294
  } / ["] content:(!["] . )* ["] {
267
295
  def value
268
- text_value[1...-1]
296
+ content.text_value
269
297
  end
270
298
  }
271
299
  end
@@ -285,18 +313,17 @@ grammar Less
285
313
  ('px'/'em'/'pc'/'%'/'pt'/'cm'/'mm')?
286
314
  end
287
315
 
288
-
289
316
  #
290
317
  # Color
291
318
  #
292
319
  rule color
293
320
  '#' rgb {
294
- def build env
295
- env.identifiers.last << Node::Color.new(*rgb.build)
321
+ def build
322
+ Node::Color.new(*rgb.build)
296
323
  end
297
324
  } / fn:(('hsl'/'rgb') 'a'?) arguments {
298
- def build env
299
- env.identifiers.last << Node::Function.new(fn.text_value, arguments.build.flatten)
325
+ def build
326
+ Node::Function.new(fn.text_value, arguments.build.flatten)
300
327
  end
301
328
  }
302
329
  end
@@ -325,8 +352,8 @@ grammar Less
325
352
  #
326
353
  rule function
327
354
  name:([-a-zA-Z_]+) arguments {
328
- def build env
329
- env.identifiers.last << Node::Function.new(name.text_value, [arguments.build].flatten)
355
+ def build
356
+ Node::Function.new(name.text_value, [arguments.build].flatten)
330
357
  end
331
358
  }
332
359
  end
@@ -69,5 +69,11 @@ module Less
69
69
  self
70
70
  end
71
71
  end
72
+
73
+ class Paren < ::String
74
+ def to_ruby
75
+ self
76
+ end
77
+ end
72
78
  end
73
79
  end
@@ -135,15 +135,15 @@ module Less
135
135
  include Literal
136
136
  end
137
137
 
138
- class FontFamily < Array
138
+ class FontFamily
139
139
  include Literal
140
140
 
141
141
  def initialize family = []
142
- super family
142
+ @family = family
143
143
  end
144
144
 
145
145
  def to_css
146
- self.map(&:to_css) * ', '
146
+ @family.map(&:to_css) * ', '
147
147
  end
148
148
  end
149
149
 
@@ -5,14 +5,23 @@ module Less
5
5
 
6
6
  attr_accessor :value
7
7
 
8
- def initialize key, value = nil
9
- super key
10
- @value = Expression.new(value ? [value].flatten : [])
8
+ def initialize key, value = nil, parent = nil
9
+ super key, parent
10
+
11
+ value = if value.is_a? Array
12
+ value.each {|v| v.parent = self if v.respond_to? :parent }
13
+ elsif value.nil?
14
+ []
15
+ else
16
+ value
17
+ end
18
+
19
+ @value = Expression.new(value, self)
11
20
  @eval = false # Store the first evaluation in here
12
21
  end
13
22
 
14
23
  def << token
15
- token = Node::Anonymous.new(*token) unless token.is_a? Entity or token.is_a? Operator
24
+ token = Node::Anonymous.new(*token) unless token.is_a? Entity or token.respond_to? :to_ruby
16
25
  token.parent = self if token.respond_to? :parent
17
26
  @value << token
18
27
  end
@@ -45,9 +54,9 @@ module Less
45
54
  class Variable < Property
46
55
  attr_reader :declaration
47
56
 
48
- def initialize key, value = nil
57
+ def initialize key, value = nil, parent = nil
49
58
  @declaration = value ? true : false
50
- super key.delete('@'), value
59
+ super key.delete('@'), value, parent
51
60
  end
52
61
 
53
62
  def inspect
@@ -76,55 +85,65 @@ module Less
76
85
  end
77
86
 
78
87
  class Expression < Array
79
- def initialize ary
80
- super [ary].flatten
88
+ attr_reader :parent
89
+
90
+ def initialize ary, parent = nil
91
+ self.parent = parent
92
+ super ary
93
+ end
94
+
95
+ def expressions; select {|i| i.kind_of? Expression } end
96
+ def operators; select {|i| i.is_a? Operator } end
97
+ def entities; select {|i| i.kind_of? Entity } end
98
+ def literals; select {|i| i.kind_of? Literal } end
99
+
100
+ def parent= obj
101
+ @parent = obj
102
+ each {|e| e.parent = obj if e.respond_to? :parent }
81
103
  end
82
104
 
83
- def operators; select {|i| i.is_a? Operator } end
84
- def entities; select {|i| i.kind_of? Entity } end
85
- def literals; select {|i| i.kind_of? Literal } end
86
-
87
105
  def inspect
88
106
  '[' + map {|i| i.inspect }.join(', ') + ']'
89
107
  end
108
+
109
+ def terminal?
110
+ expressions.empty?
111
+ end
90
112
 
91
113
  def to_css
92
- map {|i| i.to_css } * ' '
114
+ map do |i|
115
+ i.respond_to?(:to_css) ? i.to_css : i.to_s
116
+ end * ' '
117
+ end
118
+
119
+ def to_ruby
120
+ map do |i|
121
+ i.respond_to?(:to_ruby) ? i.to_ruby : i.to_s
122
+ end
93
123
  end
94
124
 
95
125
  #
96
126
  # Evaluates the expression and instantiates a new Literal with the result
97
127
  # ex: [#111, +, #111] will evaluate to a Color node, with value #222
98
128
  #
99
- # TODO: refactor the conditionals
100
129
  def evaluate
101
- if size > 2 && (entities.size == operators.size + 1)
102
-
103
- # Create a sub-expression with all the variables/properties evaluated
104
- evaluated = Expression.new map {|e| e.respond_to?(:evaluate) ? e.evaluate : e }
105
-
106
- unit = evaluated.literals.map do |node|
130
+ if size > 2 or !terminal?
131
+ # Replace self with an evaluated sub-expression
132
+ replace map {|e| e.respond_to?(:evaluate) ? e.evaluate : e }
133
+
134
+ unit = literals.map do |node|
107
135
  node.unit
108
136
  end.compact.uniq.tap do |ary|
109
137
  raise MixedUnitsError, self * ' ' if ary.size > 1
110
138
  end.join
111
-
112
- entity = evaluated.literals.find {|e| e.unit == unit } || evaluated.first
113
- ruby = map {|e| e.to_ruby if e.respond_to? :to_ruby }
114
-
115
- unless ruby.include? nil
116
- if entity
117
- result = eval(ruby.join)
118
- if result.is_a? Entity
119
- result
120
- else
121
- entity.class.new(result, *(unit if entity.class == Node::Number))
122
- end
123
- else
124
- first
125
- end
126
- else
127
- self
139
+
140
+ entity = literals.find {|e| e.unit == unit } || entities.first
141
+ result = operators.empty?? self : eval(to_ruby.join)
142
+
143
+ case result
144
+ when Entity then result
145
+ when Expression then result.one?? result.first : self.class.new(result)
146
+ else entity.class.new(result, *(unit if entity.class == Node::Number))
128
147
  end
129
148
  elsif size == 1
130
149
  first
@@ -494,7 +494,7 @@ module Less
494
494
  path = File.join(env.root.file, url.value)
495
495
  path += '.less' unless path =~ /\.(le|c)ss$/
496
496
  if File.exist? path
497
- imported = Less::Engine.new(File.new path).to_tree
497
+ imported = Less::Engine.new(File.new(path)).to_tree
498
498
  env.rules += imported.rules
499
499
  else
500
500
  raise ImportError, path
@@ -589,7 +589,7 @@ module Less
589
589
 
590
590
  module Url1
591
591
  def build env = nil
592
- Node::String.new(CGI.unescape path.text_value)
592
+ Node::String.new CGI.unescape(path.text_value)
593
593
  end
594
594
 
595
595
  def value
@@ -1039,7 +1039,7 @@ module Less
1039
1039
  elements[4]
1040
1040
  end
1041
1041
 
1042
- def expression
1042
+ def expressions
1043
1043
  elements[5]
1044
1044
  end
1045
1045
 
@@ -1054,8 +1054,9 @@ module Less
1054
1054
 
1055
1055
  module Declaration2
1056
1056
  def build env
1057
- env << (name.text_value =~ /^@/ ? Node::Variable : Node::Property).new(name.text_value, [])
1058
- expression.build env
1057
+ env << (name.text_value =~ /^@/ ?
1058
+ Node::Variable : Node::Property).new(name.text_value, expressions.build(env), env)
1059
+
1059
1060
  end
1060
1061
  # Empty rule
1061
1062
  end
@@ -1125,7 +1126,7 @@ module Less
1125
1126
  r8 = _nt_s
1126
1127
  s1 << r8
1127
1128
  if r8
1128
- r9 = _nt_expression
1129
+ r9 = _nt_expressions
1129
1130
  s1 << r9
1130
1131
  if r9
1131
1132
  r10 = _nt_s
@@ -1258,16 +1259,110 @@ module Less
1258
1259
  r0
1259
1260
  end
1260
1261
 
1262
+ module Expressions0
1263
+ def build env
1264
+ elements.map do |e|
1265
+ e.build(env) if e.respond_to? :build
1266
+ end.compact
1267
+ end
1268
+ end
1269
+
1270
+ def _nt_expressions
1271
+ start_index = index
1272
+ if node_cache[:expressions].has_key?(index)
1273
+ cached = node_cache[:expressions][index]
1274
+ @index = cached.interval.end if cached
1275
+ return cached
1276
+ end
1277
+
1278
+ s0, i0 = [], index
1279
+ loop do
1280
+ r1 = _nt_expression
1281
+ if r1
1282
+ s0 << r1
1283
+ else
1284
+ break
1285
+ end
1286
+ end
1287
+ if s0.empty?
1288
+ @index = i0
1289
+ r0 = nil
1290
+ else
1291
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
1292
+ r0.extend(Expressions0)
1293
+ end
1294
+
1295
+ node_cache[:expressions][start_index] = r0
1296
+
1297
+ r0
1298
+ end
1299
+
1261
1300
  module Expression0
1301
+ def s
1302
+ elements[0]
1303
+ end
1304
+
1305
+ def s
1306
+ elements[2]
1307
+ end
1308
+
1309
+ def expressions
1310
+ elements[3]
1311
+ end
1312
+
1313
+ def s
1314
+ elements[4]
1315
+ end
1316
+
1317
+ def s
1318
+ elements[6]
1319
+ end
1320
+ end
1321
+
1322
+ module Expression1
1323
+ def build env
1324
+ Node::Expression.new(['('] + expressions.build(env).flatten + [')'])
1325
+ end
1326
+ end
1327
+
1328
+ module Expression2
1329
+ def operator
1330
+ elements[0]
1331
+ end
1332
+
1333
+ def entity
1334
+ elements[1]
1335
+ end
1336
+ end
1337
+
1338
+ module Expression3
1262
1339
  def entity
1263
1340
  elements[0]
1264
1341
  end
1265
1342
 
1266
- def expression
1343
+ def tail
1344
+ elements[1]
1345
+ end
1346
+
1347
+ def ws
1267
1348
  elements[2]
1268
1349
  end
1269
1350
  end
1270
1351
 
1352
+ module Expression4
1353
+ def build env
1354
+ exp = all.map do |e|
1355
+ e.method(:build).arity.zero??
1356
+ e.build : e.build(env) if e.respond_to? :build
1357
+ end.dissolve
1358
+ exp.is_a?(Array) ? Node::Expression.new(exp) : exp
1359
+ end
1360
+
1361
+ def all
1362
+ [entity] + tail.elements.map {|i| [i.operator, i.entity] }.flatten.compact
1363
+ end
1364
+ end
1365
+
1271
1366
  def _nt_expression
1272
1367
  start_index = index
1273
1368
  if node_cache[:expression].has_key?(index)
@@ -1278,36 +1373,48 @@ module Less
1278
1373
 
1279
1374
  i0 = index
1280
1375
  i1, s1 = index, []
1281
- r2 = _nt_entity
1376
+ r2 = _nt_s
1282
1377
  s1 << r2
1283
1378
  if r2
1284
- i3 = index
1285
- r4 = _nt_operator
1286
- if r4
1287
- r3 = r4
1379
+ if has_terminal?('(', false, index)
1380
+ r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
1381
+ @index += 1
1288
1382
  else
1289
- r5 = _nt_S
1290
- if r5
1291
- r3 = r5
1292
- else
1293
- r6 = _nt_WS
1294
- if r6
1295
- r3 = r6
1296
- else
1297
- @index = i3
1298
- r3 = nil
1299
- end
1300
- end
1383
+ terminal_parse_failure('(')
1384
+ r3 = nil
1301
1385
  end
1302
1386
  s1 << r3
1303
1387
  if r3
1304
- r7 = _nt_expression
1305
- s1 << r7
1388
+ r4 = _nt_s
1389
+ s1 << r4
1390
+ if r4
1391
+ r5 = _nt_expressions
1392
+ s1 << r5
1393
+ if r5
1394
+ r6 = _nt_s
1395
+ s1 << r6
1396
+ if r6
1397
+ if has_terminal?(')', false, index)
1398
+ r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
1399
+ @index += 1
1400
+ else
1401
+ terminal_parse_failure(')')
1402
+ r7 = nil
1403
+ end
1404
+ s1 << r7
1405
+ if r7
1406
+ r8 = _nt_s
1407
+ s1 << r8
1408
+ end
1409
+ end
1410
+ end
1411
+ end
1306
1412
  end
1307
1413
  end
1308
1414
  if s1.last
1309
- r1 = instantiate_node(Builder,input, i1...index, s1)
1415
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
1310
1416
  r1.extend(Expression0)
1417
+ r1.extend(Expression1)
1311
1418
  else
1312
1419
  @index = i1
1313
1420
  r1 = nil
@@ -1315,9 +1422,49 @@ module Less
1315
1422
  if r1
1316
1423
  r0 = r1
1317
1424
  else
1318
- r8 = _nt_entity
1319
- if r8
1320
- r0 = r8
1425
+ i9, s9 = index, []
1426
+ r10 = _nt_entity
1427
+ s9 << r10
1428
+ if r10
1429
+ s11, i11 = [], index
1430
+ loop do
1431
+ i12, s12 = index, []
1432
+ r13 = _nt_operator
1433
+ s12 << r13
1434
+ if r13
1435
+ r14 = _nt_entity
1436
+ s12 << r14
1437
+ end
1438
+ if s12.last
1439
+ r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
1440
+ r12.extend(Expression2)
1441
+ else
1442
+ @index = i12
1443
+ r12 = nil
1444
+ end
1445
+ if r12
1446
+ s11 << r12
1447
+ else
1448
+ break
1449
+ end
1450
+ end
1451
+ r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
1452
+ s9 << r11
1453
+ if r11
1454
+ r15 = _nt_ws
1455
+ s9 << r15
1456
+ end
1457
+ end
1458
+ if s9.last
1459
+ r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
1460
+ r9.extend(Expression3)
1461
+ r9.extend(Expression4)
1462
+ else
1463
+ @index = i9
1464
+ r9 = nil
1465
+ end
1466
+ if r9
1467
+ r0 = r9
1321
1468
  else
1322
1469
  @index = i0
1323
1470
  r0 = nil
@@ -1406,11 +1553,12 @@ module Less
1406
1553
  end
1407
1554
 
1408
1555
  module Fonts2
1409
- def build env
1410
- fonts = ([font] + family.elements.map {|f| f.font }).map do |font|
1411
- font.build env
1412
- end
1413
- env.identifiers.last << Node::FontFamily.new(fonts)
1556
+ def build
1557
+ Node::FontFamily.new(all.map(&:build))
1558
+ end
1559
+
1560
+ def all
1561
+ [font] + family.elements.map {|f| f.font }
1414
1562
  end
1415
1563
  end
1416
1564
 
@@ -1488,13 +1636,13 @@ module Less
1488
1636
  end
1489
1637
 
1490
1638
  module Font1
1491
- def build env
1639
+ def build
1492
1640
  Node::Keyword.new(text_value)
1493
1641
  end
1494
1642
  end
1495
1643
 
1496
1644
  module Font2
1497
- def build env
1645
+ def build
1498
1646
  Node::String.new(text_value)
1499
1647
  end
1500
1648
  end
@@ -1640,8 +1788,8 @@ module Less
1640
1788
  end
1641
1789
 
1642
1790
  module Variable1
1643
- def build env
1644
- env.identifiers.last << Node::Variable.new(text_value)
1791
+ def build
1792
+ Node::Variable.new(text_value)
1645
1793
  end
1646
1794
  end
1647
1795
 
@@ -2394,7 +2542,7 @@ module Less
2394
2542
 
2395
2543
  module Accessor1
2396
2544
  def build env
2397
- env.identifiers.last << env.nearest(ident.text_value)[attr.text_value.delete(%q["'])].evaluate
2545
+ env.nearest(ident.text_value)[attr.text_value.delete(%q["'])].evaluate
2398
2546
  end
2399
2547
  end
2400
2548
 
@@ -2482,14 +2630,14 @@ module Less
2482
2630
  end
2483
2631
 
2484
2632
  module Operator1
2485
- def build env
2486
- env.identifiers.last << Node::Operator.new(text_value.strip)
2633
+ def build
2634
+ Node::Operator.new(text_value.strip)
2487
2635
  end
2488
2636
  end
2489
2637
 
2490
2638
  module Operator2
2491
- def build env
2492
- env.identifiers.last << Node::Operator.new(text_value)
2639
+ def build
2640
+ Node::Operator.new(text_value)
2493
2641
  end
2494
2642
  end
2495
2643
 
@@ -2556,8 +2704,8 @@ module Less
2556
2704
  end
2557
2705
 
2558
2706
  module Literal1
2559
- def build env
2560
- env.identifiers.last << Node::Anonymous.new(text_value)
2707
+ def build
2708
+ Node::Anonymous.new(text_value)
2561
2709
  end
2562
2710
  end
2563
2711
 
@@ -2572,14 +2720,14 @@ module Less
2572
2720
  end
2573
2721
 
2574
2722
  module Literal3
2575
- def build env
2576
- env.identifiers.last << Node::Number.new(number.text_value, unit.text_value)
2723
+ def build
2724
+ Node::Number.new(number.text_value, unit.text_value)
2577
2725
  end
2578
2726
  end
2579
2727
 
2580
2728
  module Literal4
2581
- def build env
2582
- env.identifiers.last << Node::String.new(text_value)
2729
+ def build
2730
+ Node::String.new(text_value)
2583
2731
  end
2584
2732
  end
2585
2733
 
@@ -2691,8 +2839,8 @@ module Less
2691
2839
  end
2692
2840
 
2693
2841
  module Important0
2694
- def build env
2695
- env.identifiers.last << Node::Keyword.new(text_value)
2842
+ def build
2843
+ Node::Keyword.new(text_value)
2696
2844
  end
2697
2845
  end
2698
2846
 
@@ -2722,8 +2870,8 @@ module Less
2722
2870
  end
2723
2871
 
2724
2872
  module Keyword1
2725
- def build env
2726
- env.identifiers.last << Node::Keyword.new(text_value)
2873
+ def build
2874
+ Node::Keyword.new(text_value)
2727
2875
  end
2728
2876
  end
2729
2877
 
@@ -2794,7 +2942,7 @@ module Less
2794
2942
 
2795
2943
  module String2
2796
2944
  def value
2797
- text_value[1...-1]
2945
+ content.text_value
2798
2946
  end
2799
2947
  end
2800
2948
 
@@ -2810,7 +2958,7 @@ module Less
2810
2958
 
2811
2959
  module String5
2812
2960
  def value
2813
- text_value[1...-1]
2961
+ content.text_value
2814
2962
  end
2815
2963
  end
2816
2964
 
@@ -3271,8 +3419,8 @@ module Less
3271
3419
  end
3272
3420
 
3273
3421
  module Color1
3274
- def build env
3275
- env.identifiers.last << Node::Color.new(*rgb.build)
3422
+ def build
3423
+ Node::Color.new(*rgb.build)
3276
3424
  end
3277
3425
  end
3278
3426
 
@@ -3290,8 +3438,8 @@ module Less
3290
3438
  end
3291
3439
 
3292
3440
  module Color4
3293
- def build env
3294
- env.identifiers.last << Node::Function.new(fn.text_value, arguments.build.flatten)
3441
+ def build
3442
+ Node::Function.new(fn.text_value, arguments.build.flatten)
3295
3443
  end
3296
3444
  end
3297
3445
 
@@ -3607,8 +3755,8 @@ module Less
3607
3755
  end
3608
3756
 
3609
3757
  module Function1
3610
- def build env
3611
- env.identifiers.last << Node::Function.new(name.text_value, [arguments.build].flatten)
3758
+ def build
3759
+ Node::Function.new(name.text_value, [arguments.build].flatten)
3612
3760
  end
3613
3761
  end
3614
3762
 
@@ -0,0 +1,7 @@
1
+ .parens {
2
+ border: 2px solid black;
3
+ margin: 1px 3px 16 3;
4
+ width: 36;
5
+ padding: 2px 36px;
6
+ }
7
+ .more-parens { padding: 8 4 4 4px; }
data/spec/engine_spec.rb CHANGED
@@ -54,6 +54,10 @@ describe Less::Engine do
54
54
  lessify(:scope).should == css(:scope)
55
55
  end
56
56
 
57
+ it "should parse parens" do
58
+ lessify(:parens).should == css(:parens)
59
+ end
60
+
57
61
  it "should parse strings" do
58
62
  lessify(:strings).should == css(:strings)
59
63
  end
@@ -36,4 +36,4 @@
36
36
  color: 2 * #111; // #222222
37
37
  border-color: #333333 / 3 + #111; // #222222
38
38
  }
39
- }
39
+ }
@@ -0,0 +1,15 @@
1
+ .parens {
2
+ @var: 1px;
3
+ border: (@var * 2) solid black;
4
+ margin: (@var * 1) (@var + 2) (4 * 4) 3;
5
+ width: (6 * 6);
6
+ padding: 2px (6px * 6px);
7
+ }
8
+
9
+ .more-parens {
10
+ @var: (2 * 2);
11
+ padding: (2 * @var) 4 4 (@var * 1px);
12
+ //width: (@var * @var) * 6;
13
+ //margin: (6 * 6)px;
14
+ //height: (7 * 7) + (8 * 8);
15
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: less
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-21 00:00:00 -04:00
12
+ date: 2009-07-23 00:00:00 -04:00
13
13
  default_executable: lessc
14
14
  dependencies: []
15
15
 
@@ -147,6 +147,7 @@ files:
147
147
  - spec/css/mixins-args.css
148
148
  - spec/css/mixins.css
149
149
  - spec/css/operations.css
150
+ - spec/css/parens.css
150
151
  - spec/css/rulesets.css
151
152
  - spec/css/scope.css
152
153
  - spec/css/selectors.css
@@ -173,6 +174,7 @@ files:
173
174
  - spec/less/mixins-args.less
174
175
  - spec/less/mixins.less
175
176
  - spec/less/operations.less
177
+ - spec/less/parens.less
176
178
  - spec/less/rulesets.less
177
179
  - spec/less/scope.less
178
180
  - spec/less/selectors.less