less 2.0.4 → 2.1.0

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.
Files changed (112) hide show
  1. data/.gitmodules +0 -3
  2. data/.travis.yml +10 -0
  3. data/README.md +1 -1
  4. data/Rakefile +2 -0
  5. data/bin/lessc +21 -2
  6. data/less.gemspec +5 -3
  7. data/lib/less/defaults.rb +13 -0
  8. data/lib/less/js/CHANGELOG +41 -0
  9. data/lib/less/js/Makefile +21 -2
  10. data/lib/less/js/benchmark/benchmark.less +11 -11
  11. data/lib/less/js/benchmark/less-benchmark.js +3 -5
  12. data/lib/less/js/bin/lessc +52 -18
  13. data/lib/less/js/build/amd.js +6 -0
  14. data/lib/less/js/build/require-rhino.js +7 -0
  15. data/lib/less/js/dist/{less-1.0.44.js → less-1.1.4.js} +159 -45
  16. data/lib/less/js/dist/less-1.1.4.min.js +16 -0
  17. data/lib/less/js/dist/less-1.1.5.js +2805 -0
  18. data/lib/less/js/dist/less-1.1.5.min.js +9 -0
  19. data/lib/less/js/dist/less-1.1.6.js +3004 -0
  20. data/lib/less/js/dist/less-1.1.6.min.js +9 -0
  21. data/lib/less/js/dist/less-1.2.0.js +3293 -0
  22. data/lib/less/js/dist/less-1.2.0.min.js +9 -0
  23. data/lib/less/js/dist/less-1.2.1.js +3318 -0
  24. data/lib/less/js/dist/less-1.2.1.min.js +9 -0
  25. data/lib/less/js/dist/less-1.2.2.js +3337 -0
  26. data/lib/less/js/dist/less-1.2.2.min.js +9 -0
  27. data/lib/less/js/dist/less-1.3.0.js +3478 -0
  28. data/lib/less/js/dist/less-1.3.0.min.js +9 -0
  29. data/lib/less/js/dist/less-rhino-1.1.3.js +2460 -0
  30. data/lib/less/js/dist/less-rhino-1.1.5.js +2481 -0
  31. data/lib/less/js/lib/less/browser.js +38 -27
  32. data/lib/less/js/lib/less/colors.js +151 -0
  33. data/lib/less/js/lib/less/cssmin.js +355 -0
  34. data/lib/less/js/lib/less/functions.js +61 -7
  35. data/lib/less/js/lib/less/index.js +48 -37
  36. data/lib/less/js/lib/less/parser.js +327 -120
  37. data/lib/less/js/lib/less/rhino.js +62 -0
  38. data/lib/less/js/lib/less/tree/alpha.js +1 -1
  39. data/lib/less/js/lib/less/tree/anonymous.js +1 -1
  40. data/lib/less/js/lib/less/tree/assignment.js +17 -0
  41. data/lib/less/js/lib/less/tree/call.js +7 -4
  42. data/lib/less/js/lib/less/tree/color.js +9 -6
  43. data/lib/less/js/lib/less/tree/comment.js +1 -1
  44. data/lib/less/js/lib/less/tree/condition.js +42 -0
  45. data/lib/less/js/lib/less/tree/dimension.js +16 -1
  46. data/lib/less/js/lib/less/tree/directive.js +4 -2
  47. data/lib/less/js/lib/less/tree/element.js +20 -5
  48. data/lib/less/js/lib/less/tree/expression.js +2 -2
  49. data/lib/less/js/lib/less/tree/import.js +16 -14
  50. data/lib/less/js/lib/less/tree/javascript.js +1 -1
  51. data/lib/less/js/lib/less/tree/keyword.js +12 -2
  52. data/lib/less/js/lib/less/tree/media.js +114 -0
  53. data/lib/less/js/lib/less/tree/mixin.js +49 -20
  54. data/lib/less/js/lib/less/tree/operation.js +1 -1
  55. data/lib/less/js/lib/less/tree/paren.js +16 -0
  56. data/lib/less/js/lib/less/tree/quoted.js +2 -2
  57. data/lib/less/js/lib/less/tree/rule.js +8 -4
  58. data/lib/less/js/lib/less/tree/ruleset.js +49 -12
  59. data/lib/less/js/lib/less/tree/selector.js +18 -4
  60. data/lib/less/js/lib/less/tree/url.js +2 -2
  61. data/lib/less/js/lib/less/tree/value.js +1 -1
  62. data/lib/less/js/lib/less/tree/variable.js +5 -3
  63. data/lib/less/js/lib/less/tree.js +6 -2
  64. data/lib/less/js/package.json +2 -2
  65. data/lib/less/js/test/css/colors.css +16 -0
  66. data/lib/less/js/test/css/comments.css +9 -5
  67. data/lib/less/js/test/css/css-3.css +18 -2
  68. data/lib/less/js/test/css/css-escapes.css +1 -1
  69. data/lib/less/js/test/css/css.css +11 -4
  70. data/lib/less/js/test/css/functions.css +13 -0
  71. data/lib/less/js/test/css/ie-filters.css +5 -0
  72. data/lib/less/js/test/css/import.css +12 -3
  73. data/lib/less/js/test/css/media.css +60 -2
  74. data/lib/less/js/test/css/mixins-args.css +17 -2
  75. data/lib/less/js/test/css/mixins-guards.css +58 -0
  76. data/lib/less/js/test/css/mixins-important.css +17 -0
  77. data/lib/less/js/test/css/mixins-pattern.css +4 -6
  78. data/lib/less/js/test/css/mixins.css +21 -0
  79. data/lib/less/js/test/css/operations.css +3 -0
  80. data/lib/less/js/test/css/parens.css +1 -1
  81. data/lib/less/js/test/css/rulesets.css +6 -2
  82. data/lib/less/js/test/css/scope.css +6 -6
  83. data/lib/less/js/test/css/selectors.css +38 -1
  84. data/lib/less/js/test/css/strings.css +6 -4
  85. data/lib/less/js/test/css/variables.css +3 -0
  86. data/lib/less/js/test/css/whitespace.css +5 -3
  87. data/lib/less/js/test/less/colors.less +19 -0
  88. data/lib/less/js/test/less/comments.less +8 -6
  89. data/lib/less/js/test/less/css-3.less +10 -0
  90. data/lib/less/js/test/less/css.less +4 -0
  91. data/lib/less/js/test/less/functions.less +15 -1
  92. data/lib/less/js/test/less/ie-filters.less +8 -0
  93. data/lib/less/js/test/less/import/import-test-e.less +2 -0
  94. data/lib/less/js/test/less/import.less +4 -1
  95. data/lib/less/js/test/less/media.less +55 -1
  96. data/lib/less/js/test/less/mixins-args.less +20 -1
  97. data/lib/less/js/test/less/mixins-guards.less +94 -0
  98. data/lib/less/js/test/less/mixins-important.less +18 -0
  99. data/lib/less/js/test/less/mixins-pattern.less +3 -0
  100. data/lib/less/js/test/less/mixins.less +20 -0
  101. data/lib/less/js/test/less/operations.less +4 -0
  102. data/lib/less/js/test/less/selectors.less +31 -0
  103. data/lib/less/js/test/less/strings.less +2 -0
  104. data/lib/less/js/test/less/variables.less +4 -0
  105. data/lib/less/js/test/less-test.js +3 -5
  106. data/lib/less/loader.rb +24 -25
  107. data/lib/less/parser.rb +32 -6
  108. data/lib/less/version.rb +1 -1
  109. data/lib/less.rb +7 -8
  110. data/spec/less/faulty/faulty.less +3 -0
  111. data/spec/less/parser_spec.rb +28 -2
  112. metadata +321 -149
data/.gitmodules CHANGED
@@ -1,6 +1,3 @@
1
- [submodule "deps/less.js"]
2
- path = deps/less.js
3
- url = http://github.com/cloudhead/less.js.git
4
1
  [submodule "lib/less/js"]
5
2
  path = lib/less/js
6
3
  url = https://github.com/cloudhead/less.js.git
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
6
+ notifications:
7
+ recipients:
8
+ - cowboyd@thefrontside.net
9
+
10
+ before_script: git submodule update --init
data/README.md CHANGED
@@ -38,4 +38,4 @@ less.rb is licensed under the same terms as less.js
38
38
  See `lib/js/LICENSE` file.
39
39
 
40
40
 
41
- > copyright 2011 Charles Lowell
41
+ > copyright 2011,2012 Charles Lowell
data/Rakefile CHANGED
@@ -5,3 +5,5 @@ require "rspec/core/rake_task"
5
5
  Bundler::GemHelper.install_tasks
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
+ task :default => :spec
9
+
data/bin/lessc CHANGED
@@ -1,5 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'less'
3
4
 
4
- puts "#{File.basename($0)}: command line invocation is not currently supported"
5
- puts " Pull requests welcome! https://github.com/cowboyd/less.rb"
5
+ # This file is inspired by / based off of http://ozmm.org/posts/argf.html
6
+
7
+ def help
8
+ puts <<-help
9
+ Usage:
10
+ $ lessc < style.less
11
+ $ lessc file1.less file2.less
12
+ help
13
+ end
14
+
15
+ # First off, let's show help some help if no arguments and tty
16
+ if ($stdin.tty? && ARGV.empty?) || ARGV.delete('-h') || ARGV.delete('--help')
17
+ help
18
+ else
19
+ # Well, lets read those files
20
+ doc = ARGF.read
21
+ parser = Less::Parser.new
22
+ tree = parser.parse(doc)
23
+ puts tree.to_css(:compress => true)
24
+ end
data/less.gemspec CHANGED
@@ -21,9 +21,11 @@ Gem::Specification.new do |s|
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
22
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
23
  s.require_paths = ["lib"]
24
-
25
- s.add_dependency "therubyracer", "~> 0.9.1"
26
- s.add_development_dependency "rake", "~> 0.9.1"
24
+
25
+ s.add_dependency "therubyracer", "~> 0.10.0"
26
+ s.add_dependency "commonjs", "~> 0.2.0"
27
+
28
+ s.add_development_dependency "rake"
27
29
  s.add_development_dependency "rspec", "~> 2.0"
28
30
  end
29
31
 
@@ -0,0 +1,13 @@
1
+
2
+ module Less
3
+ module Defaults
4
+
5
+ def defaults
6
+ @defaults ||= {:paths => []}
7
+ end
8
+
9
+ def paths
10
+ defaults[:paths]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,41 @@
1
+ 1.3.0
2
+
3
+ @media bubbling
4
+ Support arbitrary entities as selectors
5
+ Variadic argument support, see: https://gist.github.com/1933613
6
+ Behaviour of zero-arity mixins has changed, see link above.
7
+ Allow '@import' directives in any selector
8
+ Media-query features can now be a variable
9
+ Automatic merging of media-query conditions
10
+ Fix global variable leaks
11
+ Fix error message on wrong-arity call
12
+ Fix an '@arguments' behaviour bug
13
+ Fix '::' selector output
14
+ Fix a bug when using @media with mixins
15
+
16
+ 1.2.1
17
+
18
+ Fix imports on browser
19
+ Improve error reporting on browser
20
+ Fix Runtime error reports from imported files
21
+ Fix 'File not found' import error reporting
22
+
23
+ 1.2.0
24
+
25
+ Mixin guards
26
+ New function `percentage`
27
+ New `color` function to parse hex color strings
28
+ New type-checking stylesheet functions
29
+ Fix Rhino support
30
+ Fix bug in string arguments to mixin call
31
+ Fix error reporting when index is 0
32
+ Fix browser support in webkit and IE
33
+ Fix string interpolation bug when var is empty
34
+ Support '!important' after mixin calls
35
+ Support vanilla @keyframes directive
36
+ Support variables in certain css selectors, like 'nth-child'
37
+ Support @media and @import features properly
38
+ Improve @import support with media features
39
+ Improve error reports from imported files
40
+ Improve function call error reporting
41
+ Improve error-reporting
data/lib/less/js/Makefile CHANGED
@@ -18,6 +18,7 @@ HEADER = build/header.js
18
18
  VERSION = `cat package.json | grep version \
19
19
  | grep -o '[0-9]\.[0-9]\.[0-9]\+'`
20
20
  DIST = dist/less-${VERSION}.js
21
+ RHINO = dist/less-rhino-${VERSION}.js
21
22
  DIST_MIN = dist/less-${VERSION}.min.js
22
23
 
23
24
  less:
@@ -26,19 +27,37 @@ less:
26
27
  @@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST}
27
28
  @@echo "(function (window, undefined) {" >> ${DIST}
28
29
  @@cat build/require.js\
30
+ build/amd.js\
29
31
  build/ecma-5.js\
30
32
  ${SRC}/parser.js\
31
33
  ${SRC}/functions.js\
34
+ ${SRC}/colors.js\
32
35
  ${SRC}/tree/*.js\
33
36
  ${SRC}/tree.js\
34
37
  ${SRC}/browser.js >> ${DIST}
35
38
  @@echo "})(window);" >> ${DIST}
36
39
  @@echo ${DIST} built.
37
40
 
41
+ rhino:
42
+ @@mkdir -p dist
43
+ @@touch ${RHINO}
44
+ @@cat build/require-rhino.js\
45
+ build/ecma-5.js\
46
+ ${SRC}/parser.js\
47
+ ${SRC}/functions.js\
48
+ ${SRC}/tree/*.js\
49
+ ${SRC}/tree.js\
50
+ ${SRC}/rhino.js > ${RHINO}
51
+ @@echo ${RHINO} built.
52
+
38
53
  min: less
39
54
  @@echo minifying...
40
- @@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST_MIN}
41
- @@uglifyjs ${DIST} >> ${DIST_MIN}
55
+ @@uglifyjs ${DIST} > ${DIST_MIN}
56
+ @@echo ${DIST_MIN} built.
57
+
58
+ server: less
59
+ cp dist/less-${VERSION}.js test/html/
60
+ cd test/html && python -m SimpleHTTPServer
42
61
 
43
62
  clean:
44
63
  git rm dist/*
@@ -11,27 +11,27 @@
11
11
  @colour_positive: #ff0000;
12
12
  @colour_negative: #ff0000;
13
13
 
14
- .box_shadow () {
14
+ .box_shadow (...) {
15
15
  }
16
- .text_shadow () {
16
+ .text_shadow (...) {
17
17
  }
18
- .border_radius () {
18
+ .border_radius (...) {
19
19
  }
20
- .border_radius_top_left () {
20
+ .border_radius_top_left (...) {
21
21
  }
22
- .border_radius_top_right () {
22
+ .border_radius_top_right (...) {
23
23
  }
24
- .border_radius_bottom_right () {
24
+ .border_radius_bottom_right (...) {
25
25
  }
26
- .border_radius_bottom_left () {
26
+ .border_radius_bottom_left (...) {
27
27
  }
28
- .border_radius_top () {
28
+ .border_radius_top (...) {
29
29
  }
30
- .border_radius_right () {
30
+ .border_radius_right (...) {
31
31
  }
32
- .border_radius_bottom () {
32
+ .border_radius_bottom (...) {
33
33
  }
34
- .border_radius_left () {
34
+ .border_radius_left (...) {
35
35
  }
36
36
  div.browse {
37
37
  margin: 0 0 20px;
@@ -1,10 +1,8 @@
1
1
  var path = require('path'),
2
2
  fs = require('fs'),
3
- sys = require('sys');
3
+ sys = require('util');
4
4
 
5
- require.paths.unshift(__dirname, path.join(__dirname, '..'));
6
-
7
- var less = require('lib/less');
5
+ var less = require('../lib/less');
8
6
  var file = path.join(__dirname, 'benchmark.less');
9
7
 
10
8
  if (process.argv[2]) { file = path.join(process.cwd(), process.argv[2]) }
@@ -12,7 +10,7 @@ if (process.argv[2]) { file = path.join(process.cwd(), process.argv[2]) }
12
10
  fs.readFile(file, 'utf8', function (e, data) {
13
11
  var tree, css, start, end, total;
14
12
 
15
- sys.puts("Bechmarking...\n", path.basename(file) + " (" +
13
+ sys.puts("Benchmarking...\n", path.basename(file) + " (" +
16
14
  parseInt(data.length / 1024) + " KB)", "");
17
15
 
18
16
  start = new(Date);
@@ -2,22 +2,29 @@
2
2
 
3
3
  var path = require('path'),
4
4
  fs = require('fs'),
5
- sys = require('sys');
5
+ sys = require('util'),
6
+ os = require('os');
6
7
 
7
- require.paths.unshift(path.join(__dirname, '..', 'lib'));
8
-
9
- var less = require('less');
8
+ var less = require('../lib/less');
10
9
  var args = process.argv.slice(1);
11
10
  var options = {
12
11
  compress: false,
12
+ yuicompress: false,
13
13
  optimization: 1,
14
14
  silent: false,
15
- paths: []
15
+ paths: [],
16
+ color: true,
17
+ strictImports: false
16
18
  };
17
19
 
18
20
  args = args.filter(function (arg) {
19
21
  var match;
20
22
 
23
+ if (match = arg.match(/^-I(.+)$/)) {
24
+ options.paths.push(match[1]);
25
+ return false;
26
+ }
27
+
21
28
  if (match = arg.match(/^--?([a-z][0-9a-z-]*)(?:=([^\s]+))?$/i)) { arg = match[1] }
22
29
  else { return arg }
23
30
 
@@ -33,6 +40,9 @@ args = args.filter(function (arg) {
33
40
  case 'silent':
34
41
  options.silent = true;
35
42
  break;
43
+ case 'strict-imports':
44
+ options.strictImports = true;
45
+ break;
36
46
  case 'h':
37
47
  case 'help':
38
48
  sys.puts("usage: lessc source [destination]");
@@ -41,13 +51,17 @@ args = args.filter(function (arg) {
41
51
  case 'compress':
42
52
  options.compress = true;
43
53
  break;
54
+ case 'yui-compress':
55
+ options.yuicompress = true;
56
+ break;
57
+ case 'no-color':
58
+ options.color = false;
59
+ break;
44
60
  case 'include-path':
45
- options.paths = match[2].split(':')
61
+ options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
46
62
  .map(function(p) {
47
- if (p && p[0] == '/') {
48
- return path.join(path.dirname(input), p);
49
- } else if (p) {
50
- return path.join(process.cwd(), p);
63
+ if (p) {
64
+ return path.resolve(process.cwd(), p);
51
65
  }
52
66
  });
53
67
  break;
@@ -58,12 +72,12 @@ args = args.filter(function (arg) {
58
72
  });
59
73
 
60
74
  var input = args[1];
61
- if (input && input[0] != '/') {
62
- input = path.join(process.cwd(), input);
75
+ if (input && input != '-') {
76
+ input = path.resolve(process.cwd(), input);
63
77
  }
64
78
  var output = args[2];
65
- if (output && output[0] != '/') {
66
- output = path.join(process.cwd(), output);
79
+ if (output) {
80
+ output = path.resolve(process.cwd(), output);
67
81
  }
68
82
 
69
83
  var css, fd, tree;
@@ -73,7 +87,7 @@ if (! input) {
73
87
  process.exit(1);
74
88
  }
75
89
 
76
- fs.readFile(input, 'utf-8', function (e, data) {
90
+ var parseLessFile = function (e, data) {
77
91
  if (e) {
78
92
  sys.puts("lessc: " + e.message);
79
93
  process.exit(1);
@@ -82,14 +96,18 @@ fs.readFile(input, 'utf-8', function (e, data) {
82
96
  new(less.Parser)({
83
97
  paths: [path.dirname(input)].concat(options.paths),
84
98
  optimization: options.optimization,
85
- filename: input
99
+ filename: input,
100
+ strictImports: options.strictImports
86
101
  }).parse(data, function (err, tree) {
87
102
  if (err) {
88
103
  less.writeError(err, options);
89
104
  process.exit(1);
90
105
  } else {
91
106
  try {
92
- css = tree.toCSS({ compress: options.compress });
107
+ css = tree.toCSS({
108
+ compress: options.compress,
109
+ yuicompress: options.yuicompress
110
+ });
93
111
  if (output) {
94
112
  fd = fs.openSync(output, "w");
95
113
  fs.writeSync(fd, css, 0, "utf8");
@@ -102,4 +120,20 @@ fs.readFile(input, 'utf-8', function (e, data) {
102
120
  }
103
121
  }
104
122
  });
105
- });
123
+ };
124
+
125
+ if (input != '-') {
126
+ fs.readFile(input, 'utf-8', parseLessFile);
127
+ } else {
128
+ process.stdin.resume();
129
+ process.stdin.setEncoding('utf8');
130
+
131
+ var buffer = '';
132
+ process.stdin.on('data', function(data) {
133
+ buffer += data;
134
+ });
135
+
136
+ process.stdin.on('end', function() {
137
+ parseLessFile(false, buffer);
138
+ });
139
+ }
@@ -0,0 +1,6 @@
1
+ // amd.js
2
+ //
3
+ // Define Less as an AMD module.
4
+ if (typeof define === "function" && define.amd) {
5
+ define("less", [], function () { return less; } );
6
+ }
@@ -0,0 +1,7 @@
1
+ //
2
+ // Stub out `require` in rhino
3
+ //
4
+ function require(arg) {
5
+ return less[arg.split('/')[1]];
6
+ };
7
+