less 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/less.gemspec +2 -1
- data/lib/less/engine/less.tt +4 -4
- data/lib/less/engine/parser.rb +164 -131
- data/spec/css/import.css +1 -0
- data/spec/less/import/import-test-c.less +1 -0
- data/spec/less/import/import-test-d.css +1 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.13
|
data/less.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{less}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.13"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["cloudhead"]
|
@@ -161,6 +161,7 @@ Gem::Specification.new do |s|
|
|
161
161
|
"spec/less/import/import-test-a.less",
|
162
162
|
"spec/less/import/import-test-b.less",
|
163
163
|
"spec/less/import/import-test-c.less",
|
164
|
+
"spec/less/import/import-test-d.css",
|
164
165
|
"spec/less/lazy-eval.less",
|
165
166
|
"spec/less/mixins-args.less",
|
166
167
|
"spec/less/mixins.less",
|
data/lib/less/engine/less.tt
CHANGED
@@ -34,7 +34,7 @@ grammar Less
|
|
34
34
|
"@import" S url:(string / url) medias? s ';' ws {
|
35
35
|
def build env
|
36
36
|
path = File.join(env.root.file, url.value)
|
37
|
-
path += '.less' unless path =~ /\.
|
37
|
+
path += '.less' unless path =~ /\.(le|c)ss$/
|
38
38
|
if File.exist? path
|
39
39
|
imported = Less::Engine.new(File.new path).to_tree
|
40
40
|
env.rules += imported.rules
|
@@ -79,16 +79,16 @@ grammar Less
|
|
79
79
|
# div > p a {...}
|
80
80
|
#
|
81
81
|
rule selector
|
82
|
-
(s select element s)+ arguments? {
|
82
|
+
sel:(s select element s)+ arguments? {
|
83
83
|
def ruleset env
|
84
|
-
elements.inject(env) do |node, e|
|
84
|
+
sel.elements.inject(env) do |node, e|
|
85
85
|
node << Node::Element.new(e.element.text_value, e.select.text_value)
|
86
86
|
node.last
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
def mixin env
|
91
|
-
elements.map do |e|
|
91
|
+
sel.elements.map do |e|
|
92
92
|
Node::Element.new(e.element.text_value, e.select.text_value)
|
93
93
|
end
|
94
94
|
end
|
data/lib/less/engine/parser.rb
CHANGED
@@ -339,7 +339,7 @@ module Less
|
|
339
339
|
module Ruleset1
|
340
340
|
def build env
|
341
341
|
# Build the ruleset for each selector
|
342
|
-
selectors.build(env, :
|
342
|
+
selectors.build(env, :ruleset).each do |sel|
|
343
343
|
primary.build sel
|
344
344
|
end
|
345
345
|
end
|
@@ -361,7 +361,7 @@ module Less
|
|
361
361
|
|
362
362
|
module Ruleset3
|
363
363
|
def build env
|
364
|
-
selectors.build(env, :
|
364
|
+
selectors.build(env, :mixin).each do |path|
|
365
365
|
rules = path.inject(env.root) do |current, node|
|
366
366
|
current.descend(node.selector, node) or raise MixinNameError, path.join
|
367
367
|
end.rules
|
@@ -492,7 +492,7 @@ module Less
|
|
492
492
|
module Import1
|
493
493
|
def build env
|
494
494
|
path = File.join(env.root.file, url.value)
|
495
|
-
path += '.less' unless path =~ /\.
|
495
|
+
path += '.less' unless path =~ /\.(le|c)ss$/
|
496
496
|
if File.exist? path
|
497
497
|
imported = Less::Engine.new(File.new path).to_tree
|
498
498
|
env.rules += imported.rules
|
@@ -925,15 +925,22 @@ module Less
|
|
925
925
|
end
|
926
926
|
|
927
927
|
module Selector1
|
928
|
-
def
|
929
|
-
elements
|
928
|
+
def sel
|
929
|
+
elements[0]
|
930
|
+
end
|
931
|
+
|
932
|
+
end
|
933
|
+
|
934
|
+
module Selector2
|
935
|
+
def ruleset env
|
936
|
+
sel.elements.inject(env) do |node, e|
|
930
937
|
node << Node::Element.new(e.element.text_value, e.select.text_value)
|
931
938
|
node.last
|
932
939
|
end
|
933
940
|
end
|
934
941
|
|
935
|
-
def
|
936
|
-
elements.map do |e|
|
942
|
+
def mixin env
|
943
|
+
sel.elements.map do |e|
|
937
944
|
Node::Element.new(e.element.text_value, e.select.text_value)
|
938
945
|
end
|
939
946
|
end
|
@@ -947,42 +954,60 @@ module Less
|
|
947
954
|
return cached
|
948
955
|
end
|
949
956
|
|
950
|
-
|
957
|
+
i0, s0 = index, []
|
958
|
+
s1, i1 = [], index
|
951
959
|
loop do
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
if
|
956
|
-
|
957
|
-
|
958
|
-
if
|
959
|
-
|
960
|
-
|
961
|
-
if
|
962
|
-
|
963
|
-
|
960
|
+
i2, s2 = index, []
|
961
|
+
r3 = _nt_s
|
962
|
+
s2 << r3
|
963
|
+
if r3
|
964
|
+
r4 = _nt_select
|
965
|
+
s2 << r4
|
966
|
+
if r4
|
967
|
+
r5 = _nt_element
|
968
|
+
s2 << r5
|
969
|
+
if r5
|
970
|
+
r6 = _nt_s
|
971
|
+
s2 << r6
|
964
972
|
end
|
965
973
|
end
|
966
974
|
end
|
967
|
-
if
|
968
|
-
|
969
|
-
|
975
|
+
if s2.last
|
976
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
977
|
+
r2.extend(Selector0)
|
970
978
|
else
|
971
|
-
@index =
|
972
|
-
|
979
|
+
@index = i2
|
980
|
+
r2 = nil
|
973
981
|
end
|
974
|
-
if
|
975
|
-
|
982
|
+
if r2
|
983
|
+
s1 << r2
|
976
984
|
else
|
977
985
|
break
|
978
986
|
end
|
979
987
|
end
|
980
|
-
if
|
981
|
-
@index =
|
982
|
-
|
988
|
+
if s1.empty?
|
989
|
+
@index = i1
|
990
|
+
r1 = nil
|
983
991
|
else
|
992
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
993
|
+
end
|
994
|
+
s0 << r1
|
995
|
+
if r1
|
996
|
+
r8 = _nt_arguments
|
997
|
+
if r8
|
998
|
+
r7 = r8
|
999
|
+
else
|
1000
|
+
r7 = instantiate_node(SyntaxNode,input, index...index)
|
1001
|
+
end
|
1002
|
+
s0 << r7
|
1003
|
+
end
|
1004
|
+
if s0.last
|
984
1005
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
985
1006
|
r0.extend(Selector1)
|
1007
|
+
r0.extend(Selector2)
|
1008
|
+
else
|
1009
|
+
@index = i0
|
1010
|
+
r0 = nil
|
986
1011
|
end
|
987
1012
|
|
988
1013
|
node_cache[:selector][start_index] = r0
|
@@ -1601,7 +1626,6 @@ module Less
|
|
1601
1626
|
|
1602
1627
|
module Variable1
|
1603
1628
|
def build env
|
1604
|
-
#env.identifiers.last << env.nearest(text_value)
|
1605
1629
|
env.identifiers.last << Node::Variable.new(text_value)
|
1606
1630
|
end
|
1607
1631
|
end
|
@@ -3246,15 +3270,13 @@ module Less
|
|
3246
3270
|
end
|
3247
3271
|
|
3248
3272
|
def arguments
|
3249
|
-
elements[
|
3273
|
+
elements[1]
|
3250
3274
|
end
|
3251
|
-
|
3252
3275
|
end
|
3253
3276
|
|
3254
3277
|
module Color4
|
3255
3278
|
def build env
|
3256
|
-
|
3257
|
-
env.identifiers.last << Node::Function.new(fn.text_value, args.flatten)
|
3279
|
+
env.identifiers.last << Node::Function.new(fn.text_value, arguments.build.flatten)
|
3258
3280
|
end
|
3259
3281
|
end
|
3260
3282
|
|
@@ -3343,28 +3365,8 @@ module Less
|
|
3343
3365
|
end
|
3344
3366
|
s4 << r5
|
3345
3367
|
if r5
|
3346
|
-
|
3347
|
-
r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3348
|
-
@index += 1
|
3349
|
-
else
|
3350
|
-
terminal_parse_failure('(')
|
3351
|
-
r11 = nil
|
3352
|
-
end
|
3368
|
+
r11 = _nt_arguments
|
3353
3369
|
s4 << r11
|
3354
|
-
if r11
|
3355
|
-
r12 = _nt_arguments
|
3356
|
-
s4 << r12
|
3357
|
-
if r12
|
3358
|
-
if has_terminal?(')', false, index)
|
3359
|
-
r13 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3360
|
-
@index += 1
|
3361
|
-
else
|
3362
|
-
terminal_parse_failure(')')
|
3363
|
-
r13 = nil
|
3364
|
-
end
|
3365
|
-
s4 << r13
|
3366
|
-
end
|
3367
|
-
end
|
3368
3370
|
end
|
3369
3371
|
if s4.last
|
3370
3372
|
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
@@ -3585,15 +3587,13 @@ module Less
|
|
3585
3587
|
end
|
3586
3588
|
|
3587
3589
|
def arguments
|
3588
|
-
elements[
|
3590
|
+
elements[1]
|
3589
3591
|
end
|
3590
|
-
|
3591
3592
|
end
|
3592
3593
|
|
3593
3594
|
module Function1
|
3594
3595
|
def build env
|
3595
|
-
|
3596
|
-
env.identifiers.last << Node::Function.new(name.text_value, [args].flatten)
|
3596
|
+
env.identifiers.last << Node::Function.new(name.text_value, [arguments.build].flatten)
|
3597
3597
|
end
|
3598
3598
|
end
|
3599
3599
|
|
@@ -3628,28 +3628,8 @@ module Less
|
|
3628
3628
|
end
|
3629
3629
|
s0 << r1
|
3630
3630
|
if r1
|
3631
|
-
|
3632
|
-
r3 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3633
|
-
@index += 1
|
3634
|
-
else
|
3635
|
-
terminal_parse_failure('(')
|
3636
|
-
r3 = nil
|
3637
|
-
end
|
3631
|
+
r3 = _nt_arguments
|
3638
3632
|
s0 << r3
|
3639
|
-
if r3
|
3640
|
-
r4 = _nt_arguments
|
3641
|
-
s0 << r4
|
3642
|
-
if r4
|
3643
|
-
if has_terminal?(')', false, index)
|
3644
|
-
r5 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3645
|
-
@index += 1
|
3646
|
-
else
|
3647
|
-
terminal_parse_failure(')')
|
3648
|
-
r5 = nil
|
3649
|
-
end
|
3650
|
-
s0 << r5
|
3651
|
-
end
|
3652
|
-
end
|
3653
3633
|
end
|
3654
3634
|
if s0.last
|
3655
3635
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
@@ -3666,29 +3646,48 @@ module Less
|
|
3666
3646
|
end
|
3667
3647
|
|
3668
3648
|
module Arguments0
|
3649
|
+
def s
|
3650
|
+
elements[1]
|
3651
|
+
end
|
3652
|
+
|
3669
3653
|
def argument
|
3670
|
-
elements[
|
3654
|
+
elements[2]
|
3671
3655
|
end
|
3672
3656
|
|
3657
|
+
def s
|
3658
|
+
elements[3]
|
3659
|
+
end
|
3660
|
+
end
|
3661
|
+
|
3662
|
+
module Arguments1
|
3673
3663
|
def s
|
3674
3664
|
elements[1]
|
3675
3665
|
end
|
3676
3666
|
|
3667
|
+
def argument
|
3668
|
+
elements[2]
|
3669
|
+
end
|
3670
|
+
|
3677
3671
|
def s
|
3678
3672
|
elements[3]
|
3679
3673
|
end
|
3680
3674
|
|
3681
|
-
def
|
3675
|
+
def tail
|
3682
3676
|
elements[4]
|
3683
3677
|
end
|
3678
|
+
|
3684
3679
|
end
|
3685
3680
|
|
3686
|
-
module
|
3687
|
-
def build
|
3688
|
-
|
3689
|
-
e.build
|
3681
|
+
module Arguments2
|
3682
|
+
def build
|
3683
|
+
all.map do |e|
|
3684
|
+
e.build if e.respond_to? :build
|
3690
3685
|
end.compact
|
3691
3686
|
end
|
3687
|
+
|
3688
|
+
def all
|
3689
|
+
[argument] + tail.elements.map {|e| e.argument }
|
3690
|
+
end
|
3692
3691
|
end
|
3693
3692
|
|
3694
3693
|
def _nt_arguments
|
@@ -3699,51 +3698,85 @@ module Less
|
|
3699
3698
|
return cached
|
3700
3699
|
end
|
3701
3700
|
|
3702
|
-
i0 = index
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
if r2
|
3707
|
-
r3 = _nt_s
|
3708
|
-
s1 << r3
|
3709
|
-
if r3
|
3710
|
-
if has_terminal?(',', false, index)
|
3711
|
-
r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3712
|
-
@index += 1
|
3713
|
-
else
|
3714
|
-
terminal_parse_failure(',')
|
3715
|
-
r4 = nil
|
3716
|
-
end
|
3717
|
-
s1 << r4
|
3718
|
-
if r4
|
3719
|
-
r5 = _nt_s
|
3720
|
-
s1 << r5
|
3721
|
-
if r5
|
3722
|
-
r6 = _nt_arguments
|
3723
|
-
s1 << r6
|
3724
|
-
end
|
3725
|
-
end
|
3726
|
-
end
|
3727
|
-
end
|
3728
|
-
if s1.last
|
3729
|
-
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
3730
|
-
r1.extend(Arguments0)
|
3731
|
-
r1.extend(Arguments1)
|
3701
|
+
i0, s0 = index, []
|
3702
|
+
if has_terminal?('(', false, index)
|
3703
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3704
|
+
@index += 1
|
3732
3705
|
else
|
3733
|
-
|
3706
|
+
terminal_parse_failure('(')
|
3734
3707
|
r1 = nil
|
3735
3708
|
end
|
3709
|
+
s0 << r1
|
3736
3710
|
if r1
|
3737
|
-
|
3738
|
-
|
3739
|
-
|
3740
|
-
|
3741
|
-
|
3742
|
-
|
3743
|
-
|
3744
|
-
|
3711
|
+
r2 = _nt_s
|
3712
|
+
s0 << r2
|
3713
|
+
if r2
|
3714
|
+
r3 = _nt_argument
|
3715
|
+
s0 << r3
|
3716
|
+
if r3
|
3717
|
+
r4 = _nt_s
|
3718
|
+
s0 << r4
|
3719
|
+
if r4
|
3720
|
+
s5, i5 = [], index
|
3721
|
+
loop do
|
3722
|
+
i6, s6 = index, []
|
3723
|
+
if has_terminal?(',', false, index)
|
3724
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3725
|
+
@index += 1
|
3726
|
+
else
|
3727
|
+
terminal_parse_failure(',')
|
3728
|
+
r7 = nil
|
3729
|
+
end
|
3730
|
+
s6 << r7
|
3731
|
+
if r7
|
3732
|
+
r8 = _nt_s
|
3733
|
+
s6 << r8
|
3734
|
+
if r8
|
3735
|
+
r9 = _nt_argument
|
3736
|
+
s6 << r9
|
3737
|
+
if r9
|
3738
|
+
r10 = _nt_s
|
3739
|
+
s6 << r10
|
3740
|
+
end
|
3741
|
+
end
|
3742
|
+
end
|
3743
|
+
if s6.last
|
3744
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
3745
|
+
r6.extend(Arguments0)
|
3746
|
+
else
|
3747
|
+
@index = i6
|
3748
|
+
r6 = nil
|
3749
|
+
end
|
3750
|
+
if r6
|
3751
|
+
s5 << r6
|
3752
|
+
else
|
3753
|
+
break
|
3754
|
+
end
|
3755
|
+
end
|
3756
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
3757
|
+
s0 << r5
|
3758
|
+
if r5
|
3759
|
+
if has_terminal?(')', false, index)
|
3760
|
+
r11 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
3761
|
+
@index += 1
|
3762
|
+
else
|
3763
|
+
terminal_parse_failure(')')
|
3764
|
+
r11 = nil
|
3765
|
+
end
|
3766
|
+
s0 << r11
|
3767
|
+
end
|
3768
|
+
end
|
3769
|
+
end
|
3745
3770
|
end
|
3746
3771
|
end
|
3772
|
+
if s0.last
|
3773
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
3774
|
+
r0.extend(Arguments1)
|
3775
|
+
r0.extend(Arguments2)
|
3776
|
+
else
|
3777
|
+
@index = i0
|
3778
|
+
r0 = nil
|
3779
|
+
end
|
3747
3780
|
|
3748
3781
|
node_cache[:arguments][start_index] = r0
|
3749
3782
|
|
@@ -3751,7 +3784,7 @@ module Less
|
|
3751
3784
|
end
|
3752
3785
|
|
3753
3786
|
module Argument0
|
3754
|
-
def build
|
3787
|
+
def build
|
3755
3788
|
Node::Color.new text_value
|
3756
3789
|
end
|
3757
3790
|
end
|
@@ -3767,13 +3800,13 @@ module Less
|
|
3767
3800
|
end
|
3768
3801
|
|
3769
3802
|
module Argument2
|
3770
|
-
def build
|
3803
|
+
def build
|
3771
3804
|
Node::Number.new number.text_value, unit.text_value
|
3772
3805
|
end
|
3773
3806
|
end
|
3774
3807
|
|
3775
3808
|
module Argument3
|
3776
|
-
def build
|
3809
|
+
def build
|
3777
3810
|
Node::String.new text_value
|
3778
3811
|
end
|
3779
3812
|
end
|
@@ -3785,13 +3818,13 @@ module Less
|
|
3785
3818
|
end
|
3786
3819
|
|
3787
3820
|
module Argument5
|
3788
|
-
def build
|
3821
|
+
def build
|
3789
3822
|
Node::Anonymous.new text_value
|
3790
3823
|
end
|
3791
3824
|
end
|
3792
3825
|
|
3793
3826
|
module Argument6
|
3794
|
-
def build
|
3827
|
+
def build
|
3795
3828
|
Node::String.new text_value
|
3796
3829
|
end
|
3797
3830
|
end
|
data/spec/css/import.css
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
#css { color: yellow; }
|
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.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cloudhead
|
@@ -168,6 +168,7 @@ files:
|
|
168
168
|
- spec/less/import/import-test-a.less
|
169
169
|
- spec/less/import/import-test-b.less
|
170
170
|
- spec/less/import/import-test-c.less
|
171
|
+
- spec/less/import/import-test-d.css
|
171
172
|
- spec/less/lazy-eval.less
|
172
173
|
- spec/less/mixins-args.less
|
173
174
|
- spec/less/mixins.less
|