less 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.6
1
+ 1.0.8
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{less}
5
- s.version = "1.0.6"
5
+ s.version = "1.0.8"
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-14}
9
+ s.date = %q{2009-07-15}
10
10
  s.default_executable = %q{lessc}
11
11
  s.description = %q{LESS is leaner CSS}
12
12
  s.email = %q{self@cloudhead.net}
@@ -129,6 +129,7 @@ Gem::Specification.new do |s|
129
129
  "spec/command_spec.rb",
130
130
  "spec/css/accessors-1.0.css",
131
131
  "spec/css/big-1.0.css",
132
+ "spec/css/colors-1.0.css",
132
133
  "spec/css/comments-1.0.css",
133
134
  "spec/css/css-1.0.css",
134
135
  "spec/css/functions-1.0.css",
@@ -113,7 +113,7 @@ grammar Less
113
113
  # An operation or compound value
114
114
  #
115
115
  rule expression
116
- entity (operator / S) expression <Builder> / entity
116
+ entity (operator / S / WS) expression <Builder> / entity
117
117
  end
118
118
 
119
119
  #
@@ -165,7 +165,7 @@ grammar Less
165
165
  # div / .class / #id / input[type="text"] / lang(fr)
166
166
  #
167
167
  rule element
168
- (class_id / tag / ident) attribute* ('(' ident ')')? / '@media' / '@font-face'
168
+ (class_id / tag / ident) attribute* ('(' ident ')')? / attribute+ / '@media' / '@font-face'
169
169
  end
170
170
 
171
171
  rule class_id
@@ -248,7 +248,7 @@ grammar Less
248
248
  # `blue`, `small`, `normal` etc.
249
249
  #
250
250
  rule keyword
251
- [a-zA-Z] [-a-zA-Z]* !ns {
251
+ [-a-zA-Z]+ !ns {
252
252
  def build env
253
253
  env.identifiers.last << Node::Keyword.new(text_value)
254
254
  end
@@ -367,6 +367,10 @@ grammar Less
367
367
  [\n ]*
368
368
  end
369
369
 
370
+ rule WS
371
+ [\n ]+
372
+ end
373
+
370
374
  # Non-space char
371
375
  rule ns
372
376
  ![ ;\n] .
@@ -13,14 +13,21 @@ module Less
13
13
  #
14
14
  class Color < DelegateClass(Fixnum)
15
15
  include Literal
16
- attr_reader :color
16
+ attr_reader :color, :opacity
17
17
 
18
18
  def initialize color = nil, opacity = 1.0
19
+ @opacity = opacity
19
20
  @color = if color.is_a? Array
20
21
  rgba color
21
22
  elsif color.is_a? ::String
22
23
  color.delete! unit
23
- (color * ( color.length < 6 ? 6 / color.length : 1 )).to_i 16
24
+ if color.length == 3
25
+ color.split(//).map {|v| v + v }.join('').to_i 16
26
+ elsif color.length == 6
27
+ color.to_i 16
28
+ else
29
+ color
30
+ end
24
31
  else
25
32
  color
26
33
  end
@@ -31,12 +38,17 @@ module Less
31
38
  '#'
32
39
  end
33
40
 
41
+ def hex
42
+ v = [[to_i, 0].max, 256 ** 3].min
43
+ "%06x" % [v]
44
+ end
45
+
34
46
  def to_css
35
- unit + if self <= 0
36
- '0' * 6
47
+ if opacity and opacity < 1.0
48
+ colors = hex.scan(/../).map {|v| v.to_i(16) }.join(", ")
49
+ "rgba(#{colors}, #{opacity})"
37
50
  else
38
- hex = self.to_i.to_s(16)
39
- '0' * (6 - hex.length) + hex
51
+ unit + hex
40
52
  end
41
53
  end
42
54
 
@@ -1265,14 +1265,19 @@ module Less
1265
1265
  if r5
1266
1266
  r3 = r5
1267
1267
  else
1268
- @index = i3
1269
- r3 = nil
1268
+ r6 = _nt_WS
1269
+ if r6
1270
+ r3 = r6
1271
+ else
1272
+ @index = i3
1273
+ r3 = nil
1274
+ end
1270
1275
  end
1271
1276
  end
1272
1277
  s1 << r3
1273
1278
  if r3
1274
- r6 = _nt_expression
1275
- s1 << r6
1279
+ r7 = _nt_expression
1280
+ s1 << r7
1276
1281
  end
1277
1282
  end
1278
1283
  if s1.last
@@ -1285,9 +1290,9 @@ module Less
1285
1290
  if r1
1286
1291
  r0 = r1
1287
1292
  else
1288
- r7 = _nt_entity
1289
- if r7
1290
- r0 = r7
1293
+ r8 = _nt_entity
1294
+ if r8
1295
+ r0 = r8
1291
1296
  else
1292
1297
  @index = i0
1293
1298
  r0 = nil
@@ -1754,28 +1759,47 @@ module Less
1754
1759
  if r1
1755
1760
  r0 = r1
1756
1761
  else
1757
- if has_terminal?('@media', false, index)
1758
- r13 = instantiate_node(SyntaxNode,input, index...(index + 6))
1759
- @index += 6
1760
- else
1761
- terminal_parse_failure('@media')
1762
+ s13, i13 = [], index
1763
+ loop do
1764
+ r14 = _nt_attribute
1765
+ if r14
1766
+ s13 << r14
1767
+ else
1768
+ break
1769
+ end
1770
+ end
1771
+ if s13.empty?
1772
+ @index = i13
1762
1773
  r13 = nil
1774
+ else
1775
+ r13 = instantiate_node(SyntaxNode,input, i13...index, s13)
1763
1776
  end
1764
1777
  if r13
1765
1778
  r0 = r13
1766
1779
  else
1767
- if has_terminal?('@font-face', false, index)
1768
- r14 = instantiate_node(SyntaxNode,input, index...(index + 10))
1769
- @index += 10
1780
+ if has_terminal?('@media', false, index)
1781
+ r15 = instantiate_node(SyntaxNode,input, index...(index + 6))
1782
+ @index += 6
1770
1783
  else
1771
- terminal_parse_failure('@font-face')
1772
- r14 = nil
1784
+ terminal_parse_failure('@media')
1785
+ r15 = nil
1773
1786
  end
1774
- if r14
1775
- r0 = r14
1787
+ if r15
1788
+ r0 = r15
1776
1789
  else
1777
- @index = i0
1778
- r0 = nil
1790
+ if has_terminal?('@font-face', false, index)
1791
+ r16 = instantiate_node(SyntaxNode,input, index...(index + 10))
1792
+ @index += 10
1793
+ else
1794
+ terminal_parse_failure('@font-face')
1795
+ r16 = nil
1796
+ end
1797
+ if r16
1798
+ r0 = r16
1799
+ else
1800
+ @index = i0
1801
+ r0 = nil
1802
+ end
1779
1803
  end
1780
1804
  end
1781
1805
  end
@@ -2658,41 +2682,37 @@ module Less
2658
2682
  end
2659
2683
 
2660
2684
  i0, s0 = index, []
2661
- if has_terminal?('[a-zA-Z]', true, index)
2662
- r1 = true
2663
- @index += 1
2664
- else
2685
+ s1, i1 = [], index
2686
+ loop do
2687
+ if has_terminal?('[-a-zA-Z]', true, index)
2688
+ r2 = true
2689
+ @index += 1
2690
+ else
2691
+ r2 = nil
2692
+ end
2693
+ if r2
2694
+ s1 << r2
2695
+ else
2696
+ break
2697
+ end
2698
+ end
2699
+ if s1.empty?
2700
+ @index = i1
2665
2701
  r1 = nil
2702
+ else
2703
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
2666
2704
  end
2667
2705
  s0 << r1
2668
2706
  if r1
2669
- s2, i2 = [], index
2670
- loop do
2671
- if has_terminal?('[-a-zA-Z]', true, index)
2672
- r3 = true
2673
- @index += 1
2674
- else
2675
- r3 = nil
2676
- end
2677
- if r3
2678
- s2 << r3
2679
- else
2680
- break
2681
- end
2682
- end
2683
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
2684
- s0 << r2
2685
- if r2
2686
- i4 = index
2687
- r5 = _nt_ns
2688
- if r5
2689
- r4 = nil
2690
- else
2691
- @index = i4
2692
- r4 = instantiate_node(SyntaxNode,input, index...index)
2693
- end
2694
- s0 << r4
2707
+ i3 = index
2708
+ r4 = _nt_ns
2709
+ if r4
2710
+ r3 = nil
2711
+ else
2712
+ @index = i3
2713
+ r3 = instantiate_node(SyntaxNode,input, index...index)
2695
2714
  end
2715
+ s0 << r3
2696
2716
  end
2697
2717
  if s0.last
2698
2718
  r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
@@ -3846,6 +3866,40 @@ module Less
3846
3866
  r0
3847
3867
  end
3848
3868
 
3869
+ def _nt_WS
3870
+ start_index = index
3871
+ if node_cache[:WS].has_key?(index)
3872
+ cached = node_cache[:WS][index]
3873
+ @index = cached.interval.end if cached
3874
+ return cached
3875
+ end
3876
+
3877
+ s0, i0 = [], index
3878
+ loop do
3879
+ if has_terminal?('[\\n ]', true, index)
3880
+ r1 = true
3881
+ @index += 1
3882
+ else
3883
+ r1 = nil
3884
+ end
3885
+ if r1
3886
+ s0 << r1
3887
+ else
3888
+ break
3889
+ end
3890
+ end
3891
+ if s0.empty?
3892
+ @index = i0
3893
+ r0 = nil
3894
+ else
3895
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
3896
+ end
3897
+
3898
+ node_cache[:WS][start_index] = r0
3899
+
3900
+ r0
3901
+ end
3902
+
3849
3903
  module Ns0
3850
3904
  end
3851
3905
 
@@ -0,0 +1,6 @@
1
+ #yelow #short { color: #ffeeaa; }
2
+ #yelow #long { color: #ffeeaa; }
3
+ #yelow #rgba { color: rgba(255, 238, 170, 0.1); }
4
+ #blue #short { color: #0000ff; }
5
+ #blue #long { color: #0000ff; }
6
+ #blue #rgba { color: rgba(0, 0, 255, 0.1); }
@@ -22,6 +22,7 @@ q:lang(no) { quotes: none; }
22
22
  p + h1 { font-size: 2.2em; }
23
23
  input[type="text"] { font-weight: normal; }
24
24
  h2[title] { font-size: 100%; }
25
+ [disabled] { color: transparent; }
25
26
  #shorthands {
26
27
  border: 1px solid #000000;
27
28
  font: 12px/16px Arial;
@@ -36,6 +37,7 @@ h2[title] { font-size: 100%; }
36
37
  }
37
38
  .misc {
38
39
  -moz-border-radius: 2px;
40
+ display: -moz-inline-stack;
39
41
  width: 0.1em;
40
42
  background-color: #009998;
41
43
  color: red !important;
@@ -18,8 +18,8 @@
18
18
  }
19
19
  .shorthands { padding: -1px 2px 0 -4px; }
20
20
  .colors {
21
- color: #123123;
22
- border-color: #345345;
21
+ color: #112233;
22
+ border-color: #334455;
23
23
  background-color: #000000;
24
24
  }
25
25
  .colors .other {
@@ -1,6 +1,6 @@
1
1
  .tiny-scope {
2
2
  color: none;
3
- border-color: #989989;
3
+ border-color: #998899;
4
4
  }
5
5
  .scope1 {
6
6
  color: blue;
@@ -11,3 +11,4 @@
11
11
  color: white;
12
12
  white-space: pre;
13
13
  }
14
+ .newlines { border: 2px solid black; }
@@ -54,6 +54,10 @@ describe Less::Engine do
54
54
  lessify(:accessors).should == css(:accessors)
55
55
  end
56
56
 
57
+ it "should parse colors in hex" do
58
+ lessify(:colors).should == css(:colors)
59
+ end
60
+
57
61
  it "should parse mixins" do
58
62
  lessify(:mixins).should == css(:mixins)
59
63
  end
@@ -0,0 +1,27 @@
1
+ #yelow {
2
+ #short {
3
+ color: #fea;
4
+ }
5
+
6
+ #long {
7
+ color: #ffeeaa;
8
+ }
9
+
10
+ #rgba {
11
+ color: rgba(255, 238, 170, 0.1);
12
+ }
13
+ }
14
+
15
+ #blue {
16
+ #short {
17
+ color: #00f;
18
+ }
19
+
20
+ #long {
21
+ color: #0000ff;
22
+ }
23
+
24
+ #rgba {
25
+ color: rgba(0, 0, 255, 0.1);
26
+ }
27
+ }
@@ -68,6 +68,10 @@ h2[title] {
68
68
  font-size: 100%;
69
69
  }
70
70
 
71
+ [disabled] {
72
+ color: transparent;
73
+ }
74
+
71
75
  #shorthands {
72
76
  border: 1px solid #000;
73
77
  font: 12px/16px Arial;
@@ -84,6 +88,7 @@ h2[title] {
84
88
 
85
89
  .misc {
86
90
  -moz-border-radius: 2px;
91
+ display: -moz-inline-stack;
87
92
  width: .1em;
88
93
  background-color: #009998;
89
94
  color: red !important;
@@ -29,8 +29,8 @@
29
29
  }
30
30
 
31
31
  .colors {
32
- color: #123; // #123123
33
- border-color: #234 + #111111; // #345345
32
+ color: #123; // #112233
33
+ border-color: #234 + #111111; // #334455
34
34
  background-color: #222222 - #fff; // #000000
35
35
  .other {
36
36
  color: 2 * #111; // #222222
@@ -20,6 +20,11 @@
20
20
  color: white;
21
21
  white-space: pre
22
22
  }
23
+ .newlines {
24
+ border: 2px
25
+ solid
26
+ black;
27
+ }
23
28
  .empty {
24
29
 
25
30
  }
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.6
4
+ version: 1.0.8
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-14 00:00:00 -04:00
12
+ date: 2009-07-15 00:00:00 -04:00
13
13
  default_executable: lessc
14
14
  dependencies: []
15
15
 
@@ -136,6 +136,7 @@ files:
136
136
  - spec/command_spec.rb
137
137
  - spec/css/accessors-1.0.css
138
138
  - spec/css/big-1.0.css
139
+ - spec/css/colors-1.0.css
139
140
  - spec/css/comments-1.0.css
140
141
  - spec/css/css-1.0.css
141
142
  - spec/css/functions-1.0.css