sass 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +58 -50
- data/Rakefile +1 -4
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/VERSION_NAME +1 -1
- data/bin/sass +1 -1
- data/bin/scss +1 -1
- data/lib/sass/cache_stores/filesystem.rb +6 -2
- data/lib/sass/css.rb +1 -3
- data/lib/sass/engine.rb +37 -46
- data/lib/sass/environment.rb +13 -17
- data/lib/sass/error.rb +6 -9
- data/lib/sass/exec/base.rb +187 -0
- data/lib/sass/exec/sass_convert.rb +264 -0
- data/lib/sass/exec/sass_scss.rb +424 -0
- data/lib/sass/exec.rb +5 -771
- data/lib/sass/features.rb +7 -0
- data/lib/sass/importers/base.rb +7 -2
- data/lib/sass/importers/filesystem.rb +9 -25
- data/lib/sass/importers.rb +0 -1
- data/lib/sass/media.rb +1 -4
- data/lib/sass/plugin/compiler.rb +200 -83
- data/lib/sass/plugin/staleness_checker.rb +1 -1
- data/lib/sass/plugin.rb +3 -3
- data/lib/sass/script/css_lexer.rb +1 -1
- data/lib/sass/script/functions.rb +622 -268
- data/lib/sass/script/lexer.rb +99 -34
- data/lib/sass/script/parser.rb +24 -23
- data/lib/sass/script/tree/funcall.rb +1 -1
- data/lib/sass/script/tree/interpolation.rb +20 -2
- data/lib/sass/script/tree/selector.rb +26 -0
- data/lib/sass/script/tree/string_interpolation.rb +1 -1
- data/lib/sass/script/tree.rb +1 -0
- data/lib/sass/script/value/base.rb +7 -5
- data/lib/sass/script/value/bool.rb +0 -5
- data/lib/sass/script/value/color.rb +39 -21
- data/lib/sass/script/value/helpers.rb +107 -0
- data/lib/sass/script/value/list.rb +0 -15
- data/lib/sass/script/value/null.rb +0 -5
- data/lib/sass/script/value/number.rb +62 -14
- data/lib/sass/script/value/string.rb +59 -11
- data/lib/sass/script/value.rb +0 -1
- data/lib/sass/scss/css_parser.rb +8 -2
- data/lib/sass/scss/parser.rb +190 -328
- data/lib/sass/scss/rx.rb +15 -6
- data/lib/sass/scss/static_parser.rb +298 -1
- data/lib/sass/selector/abstract_sequence.rb +28 -13
- data/lib/sass/selector/comma_sequence.rb +92 -13
- data/lib/sass/selector/pseudo.rb +256 -0
- data/lib/sass/selector/sequence.rb +94 -24
- data/lib/sass/selector/simple.rb +14 -25
- data/lib/sass/selector/simple_sequence.rb +97 -33
- data/lib/sass/selector.rb +57 -194
- data/lib/sass/shared.rb +1 -1
- data/lib/sass/source/map.rb +26 -12
- data/lib/sass/stack.rb +0 -6
- data/lib/sass/supports.rb +2 -3
- data/lib/sass/tree/at_root_node.rb +1 -0
- data/lib/sass/tree/charset_node.rb +1 -1
- data/lib/sass/tree/directive_node.rb +8 -2
- data/lib/sass/tree/error_node.rb +18 -0
- data/lib/sass/tree/extend_node.rb +1 -1
- data/lib/sass/tree/function_node.rb +4 -0
- data/lib/sass/tree/keyframe_rule_node.rb +15 -0
- data/lib/sass/tree/prop_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +12 -7
- data/lib/sass/tree/visitors/check_nesting.rb +38 -10
- data/lib/sass/tree/visitors/convert.rb +16 -18
- data/lib/sass/tree/visitors/cssize.rb +29 -29
- data/lib/sass/tree/visitors/deep_copy.rb +5 -0
- data/lib/sass/tree/visitors/perform.rb +45 -33
- data/lib/sass/tree/visitors/set_options.rb +14 -0
- data/lib/sass/tree/visitors/to_css.rb +15 -14
- data/lib/sass/util/subset_map.rb +1 -1
- data/lib/sass/util.rb +222 -99
- data/lib/sass/version.rb +5 -5
- data/lib/sass.rb +0 -5
- data/test/sass/cache_test.rb +62 -20
- data/test/sass/callbacks_test.rb +1 -1
- data/test/sass/compiler_test.rb +19 -10
- data/test/sass/conversion_test.rb +58 -1
- data/test/sass/css2sass_test.rb +23 -4
- data/test/sass/encoding_test.rb +219 -0
- data/test/sass/engine_test.rb +136 -199
- data/test/sass/exec_test.rb +2 -2
- data/test/sass/extend_test.rb +236 -19
- data/test/sass/functions_test.rb +295 -253
- data/test/sass/importer_test.rb +31 -21
- data/test/sass/logger_test.rb +1 -1
- data/test/sass/more_results/more_import.css +1 -1
- data/test/sass/plugin_test.rb +14 -13
- data/test/sass/results/compact.css +1 -1
- data/test/sass/results/complex.css +4 -4
- data/test/sass/results/expanded.css +1 -1
- data/test/sass/results/import.css +1 -1
- data/test/sass/results/import_charset_ibm866.css +2 -2
- data/test/sass/results/mixins.css +17 -17
- data/test/sass/results/nested.css +1 -1
- data/test/sass/results/parent_ref.css +2 -2
- data/test/sass/results/script.css +3 -3
- data/test/sass/results/scss_import.css +1 -1
- data/test/sass/script_conversion_test.rb +10 -7
- data/test/sass/script_test.rb +288 -74
- data/test/sass/scss/css_test.rb +141 -24
- data/test/sass/scss/rx_test.rb +4 -4
- data/test/sass/scss/scss_test.rb +457 -18
- data/test/sass/source_map_test.rb +115 -25
- data/test/sass/superselector_test.rb +191 -0
- data/test/sass/templates/scss_import.scss +2 -1
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +1 -1
- data/test/sass/util/normalized_map_test.rb +1 -1
- data/test/sass/util/subset_map_test.rb +2 -2
- data/test/sass/util_test.rb +31 -1
- data/test/sass/value_helpers_test.rb +5 -7
- data/test/test_helper.rb +2 -2
- data/vendor/listen/CHANGELOG.md +1 -228
- data/vendor/listen/Gemfile +5 -15
- data/vendor/listen/README.md +111 -77
- data/vendor/listen/Rakefile +0 -42
- data/vendor/listen/lib/listen/adapter.rb +195 -82
- data/vendor/listen/lib/listen/adapters/bsd.rb +27 -64
- data/vendor/listen/lib/listen/adapters/darwin.rb +21 -58
- data/vendor/listen/lib/listen/adapters/linux.rb +23 -55
- data/vendor/listen/lib/listen/adapters/polling.rb +25 -34
- data/vendor/listen/lib/listen/adapters/windows.rb +50 -46
- data/vendor/listen/lib/listen/directory_record.rb +96 -61
- data/vendor/listen/lib/listen/listener.rb +135 -37
- data/vendor/listen/lib/listen/turnstile.rb +9 -5
- data/vendor/listen/lib/listen/version.rb +1 -1
- data/vendor/listen/lib/listen.rb +33 -19
- data/vendor/listen/listen.gemspec +6 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +43 -77
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +8 -8
- data/vendor/listen/spec/listen/directory_record_spec.rb +81 -56
- data/vendor/listen/spec/listen/listener_spec.rb +128 -39
- data/vendor/listen/spec/listen_spec.rb +15 -21
- data/vendor/listen/spec/spec_helper.rb +4 -0
- data/vendor/listen/spec/support/adapter_helper.rb +52 -15
- data/vendor/listen/spec/support/directory_record_helper.rb +7 -5
- data/vendor/listen/spec/support/listeners_helper.rb +30 -7
- metadata +25 -22
- data/ext/mkrf_conf.rb +0 -27
- data/lib/sass/importers/deprecated_path.rb +0 -51
- data/lib/sass/script/value/deprecated_false.rb +0 -55
- data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
- data/vendor/listen/lib/listen/multi_listener.rb +0 -143
- data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
- data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -174
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddad801e37fc518f7e65d22001ccfd3953ed038c
|
4
|
+
data.tar.gz: a14f945fcf23bd0fc3c34c9cd3b74c5c108fef78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f50f5f87c434e97dfb5b97fa9bd3489836f3a59a1026c95d849f0248185528ecb9f36b7436e101517d35c37814023312f58a9c111a15525164165b173313c3da
|
7
|
+
data.tar.gz: e214a6daa25e3de564b65c6443bcbfc85134c9757b1c314f98176db53c7e3fcdd119af6adc64fc99e0566dc451ad59efef89f5cbd64de46ed0d080c714ddbaf9
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006-
|
1
|
+
Copyright (c) 2006-2014 Hampton Catlin, Natalie Weizenbaum, and Chris Eppstein
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -49,8 +49,10 @@ see [the Sass reference](http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.ht
|
|
49
49
|
Sass can also be used with any Rack-enabled web framework.
|
50
50
|
To do so, just add
|
51
51
|
|
52
|
-
|
53
|
-
|
52
|
+
```ruby
|
53
|
+
require 'sass/plugin/rack'
|
54
|
+
use Sass::Plugin::Rack
|
55
|
+
```
|
54
56
|
|
55
57
|
to `config.ru`.
|
56
58
|
Then any Sass files in `public/stylesheets/sass`
|
@@ -93,18 +95,20 @@ put them in a file called `test.scss` and run `sass test.scss`.
|
|
93
95
|
Sass avoids repetition by nesting selectors within one another.
|
94
96
|
The same thing works for properties.
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
98
|
+
```scss
|
99
|
+
table.hl {
|
100
|
+
margin: 2em 0;
|
101
|
+
td.ln { text-align: right; }
|
102
|
+
}
|
103
|
+
|
104
|
+
li {
|
105
|
+
font: {
|
106
|
+
family: serif;
|
107
|
+
weight: bold;
|
108
|
+
size: 1.2em;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
```
|
108
112
|
|
109
113
|
### Variables
|
110
114
|
|
@@ -112,19 +116,21 @@ Use the same color all over the place?
|
|
112
116
|
Need to do some math with height and width and text size?
|
113
117
|
Sass supports variables, math operations, and many useful functions.
|
114
118
|
|
115
|
-
|
116
|
-
|
119
|
+
```scss
|
120
|
+
$blue: #3bbfce;
|
121
|
+
$margin: 16px;
|
117
122
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
123
|
+
.content_navigation {
|
124
|
+
border-color: $blue;
|
125
|
+
color: darken($blue, 10%);
|
126
|
+
}
|
122
127
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
+
.border {
|
129
|
+
padding: $margin / 2;
|
130
|
+
margin: $margin / 2;
|
131
|
+
border-color: $blue;
|
132
|
+
}
|
133
|
+
```
|
128
134
|
|
129
135
|
### Mixins
|
130
136
|
|
@@ -133,23 +139,25 @@ mixins allow you to re-use whole chunks of CSS,
|
|
133
139
|
properties or selectors.
|
134
140
|
You can even give them arguments.
|
135
141
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
142
|
+
```scss
|
143
|
+
@mixin table-scaffolding {
|
144
|
+
th {
|
145
|
+
text-align: center;
|
146
|
+
font-weight: bold;
|
147
|
+
}
|
148
|
+
td, th { padding: 2px; }
|
149
|
+
}
|
150
|
+
|
151
|
+
@mixin left($dist) {
|
152
|
+
float: left;
|
153
|
+
margin-left: $dist;
|
154
|
+
}
|
155
|
+
|
156
|
+
#data {
|
157
|
+
@include left(10px);
|
158
|
+
@include table-scaffolding;
|
159
|
+
}
|
160
|
+
```
|
153
161
|
|
154
162
|
A comprehensive list of features is available
|
155
163
|
in the [Sass reference](http://sass-lang.com/documentation/file.SASS_REFERENCE.html).
|
@@ -191,23 +199,23 @@ and now occasionally consults on the language issues. Hampton lives in San
|
|
191
199
|
Francisco, California and works as VP of Technology
|
192
200
|
at [Moovweb](http://www.moovweb.com/).
|
193
201
|
|
194
|
-
[
|
195
|
-
Sass.
|
202
|
+
[Natalie Weizenbaum](http://nex-3.com) is the primary developer and architect of
|
203
|
+
Sass. Her hard work has kept the project alive by endlessly answering forum
|
196
204
|
posts, fixing bugs, refactoring, finding speed improvements, writing
|
197
205
|
documentation, implementing new features, and getting Hampton coffee (a fitting
|
198
|
-
task for a
|
206
|
+
task for a girl genius). Natalie lives in Seattle, Washington and works on
|
199
207
|
[Dart](http://dartlang.org) application libraries at Google.
|
200
208
|
|
201
209
|
[Chris Eppstein](http://acts-as-architect.blogspot.com) is a core contributor to
|
202
210
|
Sass and the creator of Compass, the first Sass-based framework. Chris focuses
|
203
211
|
on making Sass more powerful, easy to use, and on ways to speed its adoption
|
204
212
|
through the web development community. Chris lives in San Jose, California with
|
205
|
-
his wife and daughter. He is
|
206
|
-
[
|
207
|
-
|
213
|
+
his wife and daughter. He is an Engineer for
|
214
|
+
[LinkedIn.com](http://linkedin.com), where one of his responsibilities is to
|
215
|
+
maintain Sass & Compass.
|
208
216
|
|
209
|
-
If you use this software, you must pay Hampton a compliment. And
|
210
|
-
|
217
|
+
If you use this software, you must pay Hampton a compliment. And buy Natalie
|
218
|
+
some candy. Maybe pet a kitten. Yeah. Pet that kitty.
|
211
219
|
|
212
220
|
Beyond that, the implementation is licensed under the MIT License.
|
213
221
|
Okay, fine, I guess that means compliments aren't __required__.
|
data/Rakefile
CHANGED
@@ -102,12 +102,10 @@ task :install => [:package] do
|
|
102
102
|
sh %{#{'sudo ' if ENV["SUDO"]}#{gem} install --no-ri pkg/sass-#{get_version}}
|
103
103
|
end
|
104
104
|
|
105
|
-
desc "Release a new Sass package to
|
105
|
+
desc "Release a new Sass package to RubyGems.org."
|
106
106
|
task :release => [:check_release, :package] do
|
107
107
|
name = File.read(scope("VERSION_NAME")).strip
|
108
108
|
version = File.read(scope("VERSION")).strip
|
109
|
-
sh %{rubyforge add_release sass sass "#{name} (v#{version})" pkg/sass-#{version}.gem}
|
110
|
-
sh %{rubyforge add_file sass sass "#{name} (v#{version})" pkg/sass-#{version}.tar.gz}
|
111
109
|
sh %{gem push pkg/sass-#{version}.gem}
|
112
110
|
end
|
113
111
|
|
@@ -166,7 +164,6 @@ task :release_edge do
|
|
166
164
|
next
|
167
165
|
end
|
168
166
|
|
169
|
-
sh %{rubyforge add_release sass sass "Bleeding Edge (v#{version})" pkg/sass-#{version}.gem}
|
170
167
|
sh %{gem push pkg/sass-#{version}.gem}
|
171
168
|
end
|
172
169
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.0
|
data/VERSION_DATE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
19 August 2014 00:38:04 UTC
|
data/VERSION_NAME
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Selective Steve
|
data/bin/sass
CHANGED
data/bin/scss
CHANGED
@@ -22,7 +22,11 @@ module Sass
|
|
22
22
|
return f.read
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
begin
|
26
|
+
File.unlink path_to(key)
|
27
|
+
rescue Errno::ENOENT
|
28
|
+
# Already deleted. Race condition?
|
29
|
+
end
|
26
30
|
nil
|
27
31
|
rescue EOFError, TypeError, ArgumentError => e
|
28
32
|
Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
|
@@ -32,7 +36,7 @@ module Sass
|
|
32
36
|
def _store(key, version, sha, contents)
|
33
37
|
compiled_filename = path_to(key)
|
34
38
|
FileUtils.mkdir_p(File.dirname(compiled_filename))
|
35
|
-
Sass::Util.atomic_create_and_write_file(compiled_filename) do |f|
|
39
|
+
Sass::Util.atomic_create_and_write_file(compiled_filename, 0600) do |f|
|
36
40
|
f.puts(version)
|
37
41
|
f.puts(sha)
|
38
42
|
f.write(contents)
|
data/lib/sass/css.rb
CHANGED
@@ -67,9 +67,7 @@ module Sass
|
|
67
67
|
def check_encoding!
|
68
68
|
return if @checked_encoding
|
69
69
|
@checked_encoding = true
|
70
|
-
@template, @original_encoding = Sass::Util.check_sass_encoding(@template)
|
71
|
-
raise Sass::SyntaxError.new(msg, :line => line)
|
72
|
-
end
|
70
|
+
@template, @original_encoding = Sass::Util.check_sass_encoding(@template)
|
73
71
|
end
|
74
72
|
|
75
73
|
# Parses the CSS template and applies various transformations
|
data/lib/sass/engine.rb
CHANGED
@@ -30,6 +30,8 @@ require 'sass/tree/warn_node'
|
|
30
30
|
require 'sass/tree/import_node'
|
31
31
|
require 'sass/tree/charset_node'
|
32
32
|
require 'sass/tree/at_root_node'
|
33
|
+
require 'sass/tree/keyframe_rule_node'
|
34
|
+
require 'sass/tree/error_node'
|
33
35
|
require 'sass/tree/visitors/base'
|
34
36
|
require 'sass/tree/visitors/perform'
|
35
37
|
require 'sass/tree/visitors/cssize'
|
@@ -190,22 +192,14 @@ module Sass
|
|
190
192
|
options[:filesystem_importer].new(p.to_s)
|
191
193
|
end
|
192
194
|
|
193
|
-
# Remove any deprecated importers if the location is imported explicitly
|
194
|
-
options[:load_paths].reject! do |importer|
|
195
|
-
importer.is_a?(Sass::Importers::DeprecatedPath) &&
|
196
|
-
options[:load_paths].find do |other_importer|
|
197
|
-
other_importer.is_a?(Sass::Importers::Filesystem) &&
|
198
|
-
other_importer != importer &&
|
199
|
-
other_importer.root == importer.root
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
195
|
# Backwards compatibility
|
204
196
|
options[:property_syntax] ||= options[:attribute_syntax]
|
205
197
|
case options[:property_syntax]
|
206
198
|
when :alternate; options[:property_syntax] = :new
|
207
199
|
when :normal; options[:property_syntax] = :old
|
208
200
|
end
|
201
|
+
options[:sourcemap] = :auto if options[:sourcemap] == true
|
202
|
+
options[:sourcemap] = :none if options[:sourcemap] == false
|
209
203
|
|
210
204
|
options
|
211
205
|
end
|
@@ -271,8 +265,8 @@ module Sass
|
|
271
265
|
# cannot be converted to UTF-8
|
272
266
|
# @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
|
273
267
|
def render
|
274
|
-
return
|
275
|
-
Sass::Util.silence_sass_warnings {
|
268
|
+
return _to_tree.render unless @options[:quiet]
|
269
|
+
Sass::Util.silence_sass_warnings {_to_tree.render}
|
276
270
|
end
|
277
271
|
|
278
272
|
# Render the template to CSS and return the source map.
|
@@ -315,7 +309,7 @@ module Sass
|
|
315
309
|
# @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
|
316
310
|
def source_encoding
|
317
311
|
check_encoding!
|
318
|
-
@
|
312
|
+
@source_encoding
|
319
313
|
end
|
320
314
|
|
321
315
|
# Gets a set of all the documents
|
@@ -360,7 +354,10 @@ Error generating source map: couldn't determine public URL for "#{filename}".
|
|
360
354
|
Without a public URL, there's nothing for the source map to link to.
|
361
355
|
An importer was not set for this file.
|
362
356
|
ERR
|
363
|
-
elsif Sass::Util.silence_warnings
|
357
|
+
elsif Sass::Util.silence_warnings do
|
358
|
+
sourcemap_dir = nil if @options[:sourcemap] == :file
|
359
|
+
importer.public_url(filename, sourcemap_dir).nil?
|
360
|
+
end
|
364
361
|
raise Sass::SyntaxError.new(<<ERR)
|
365
362
|
Error generating source map: couldn't determine public URL for "#{filename}".
|
366
363
|
Without a public URL, there's nothing for the source map to link to.
|
@@ -375,23 +372,12 @@ ERR
|
|
375
372
|
rendered << "/*# sourceMappingURL="
|
376
373
|
rendered << Sass::Util.escape_uri(sourcemap_uri)
|
377
374
|
rendered << " */\n"
|
378
|
-
rendered = encode_and_set_charset(rendered)
|
379
375
|
return rendered, sourcemap
|
380
376
|
end
|
381
377
|
|
382
|
-
def encode_and_set_charset(rendered)
|
383
|
-
return rendered if Sass::Util.ruby1_8?
|
384
|
-
begin
|
385
|
-
# Try to convert the result to the original encoding,
|
386
|
-
# but if that doesn't work fall back on UTF-8
|
387
|
-
rendered = rendered.encode(source_encoding)
|
388
|
-
rescue EncodingError
|
389
|
-
end
|
390
|
-
rendered.gsub(Regexp.new('\A@charset "(.*?)"'.encode(source_encoding)),
|
391
|
-
"@charset \"#{source_encoding.name}\"".encode(source_encoding))
|
392
|
-
end
|
393
|
-
|
394
378
|
def _to_tree
|
379
|
+
check_encoding!
|
380
|
+
|
395
381
|
if (@options[:cache] || @options[:read_cache]) &&
|
396
382
|
@options[:filename] && @options[:importer]
|
397
383
|
key = sassc_key
|
@@ -403,8 +389,6 @@ ERR
|
|
403
389
|
end
|
404
390
|
end
|
405
391
|
|
406
|
-
check_encoding!
|
407
|
-
|
408
392
|
if @options[:syntax] == :scss
|
409
393
|
root = Sass::SCSS::Parser.new(@template, @options[:filename], @options[:importer]).parse
|
410
394
|
else
|
@@ -436,9 +420,7 @@ ERR
|
|
436
420
|
def check_encoding!
|
437
421
|
return if @checked_encoding
|
438
422
|
@checked_encoding = true
|
439
|
-
@template, @
|
440
|
-
raise Sass::SyntaxError.new(msg, :line => line)
|
441
|
-
end
|
423
|
+
@template, @source_encoding = Sass::Util.check_sass_encoding(@template)
|
442
424
|
end
|
443
425
|
|
444
426
|
def tabulate(string)
|
@@ -446,7 +428,7 @@ ERR
|
|
446
428
|
comment_tab_str = nil
|
447
429
|
first = true
|
448
430
|
lines = []
|
449
|
-
string.
|
431
|
+
string.scan(/^[^\n]*?$/).each_with_index do |line, index|
|
450
432
|
index += (@options[:line] || 1)
|
451
433
|
if line.strip.empty?
|
452
434
|
lines.last.text << "\n" if lines.last && lines.last.comment?
|
@@ -792,7 +774,7 @@ WARNING
|
|
792
774
|
|
793
775
|
DIRECTIVES = Set[:mixin, :include, :function, :return, :debug, :warn, :for,
|
794
776
|
:each, :while, :if, :else, :extend, :import, :media, :charset, :content,
|
795
|
-
:at_root]
|
777
|
+
:at_root, :error]
|
796
778
|
|
797
779
|
# @comment
|
798
780
|
# rubocop:disable MethodLength
|
@@ -834,6 +816,14 @@ WARNING
|
|
834
816
|
Tree::DebugNode.new(parse_script(value, :offset => offset))
|
835
817
|
end
|
836
818
|
|
819
|
+
def parse_error_directive(parent, line, root, value, offset)
|
820
|
+
raise SyntaxError.new("Invalid error directive '@error': expected expression.") unless value
|
821
|
+
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath error directives.",
|
822
|
+
:line => @line + 1) unless line.children.empty?
|
823
|
+
offset = line.offset + line.text.index(value).to_i
|
824
|
+
Tree::ErrorNode.new(parse_script(value, :offset => offset))
|
825
|
+
end
|
826
|
+
|
837
827
|
def parse_extend_directive(parent, line, root, value, offset)
|
838
828
|
raise SyntaxError.new("Invalid extend directive '@extend': expected expression.") unless value
|
839
829
|
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath extend directives.",
|
@@ -1009,15 +999,16 @@ WARNING
|
|
1009
999
|
script_parser = Sass::Script::Parser.new(scanner, @line, to_parser_offset(offset), @options)
|
1010
1000
|
str = script_parser.parse_string
|
1011
1001
|
|
1012
|
-
|
1013
|
-
@options[:filename], @options[:importer],
|
1014
|
-
@line, str.source_range.end_pos.offset)
|
1015
|
-
if (media = media_parser.parse_media_query_list)
|
1016
|
-
end_pos = Sass::Source::Position.new(@line, media_parser.offset + 1)
|
1017
|
-
node = Tree::CssImportNode.new(str, media.to_a)
|
1018
|
-
else
|
1002
|
+
if scanner.eos?
|
1019
1003
|
end_pos = str.source_range.end_pos
|
1020
1004
|
node = Tree::CssImportNode.new(str)
|
1005
|
+
else
|
1006
|
+
media_parser = Sass::SCSS::Parser.new(scanner,
|
1007
|
+
@options[:filename], @options[:importer],
|
1008
|
+
@line, str.source_range.end_pos.offset)
|
1009
|
+
media = media_parser.parse_media_query_list
|
1010
|
+
end_pos = Sass::Source::Position.new(@line, media_parser.offset + 1)
|
1011
|
+
node = Tree::CssImportNode.new(str, media.to_a)
|
1021
1012
|
end
|
1022
1013
|
|
1023
1014
|
node.source_range = Sass::Source::Range.new(
|
@@ -1026,7 +1017,7 @@ WARNING
|
|
1026
1017
|
return node
|
1027
1018
|
end
|
1028
1019
|
|
1029
|
-
unless (
|
1020
|
+
unless (quoted_val = scanner.scan(Sass::SCSS::RX::STRING))
|
1030
1021
|
scanned = scanner.scan(/[^,;]+/)
|
1031
1022
|
node = Tree::ImportNode.new(scanned)
|
1032
1023
|
start_parser_offset = to_parser_offset(offset)
|
@@ -1038,21 +1029,21 @@ WARNING
|
|
1038
1029
|
end
|
1039
1030
|
|
1040
1031
|
start_offset = offset
|
1041
|
-
offset +=
|
1042
|
-
val = scanner[1] || scanner[2]
|
1032
|
+
offset += scanner.matched.length
|
1033
|
+
val = Sass::Script::Value::String.value(scanner[1] || scanner[2])
|
1043
1034
|
scanned = scanner.scan(/\s*/)
|
1044
1035
|
if !scanner.match?(/[,;]|$/)
|
1045
1036
|
offset += scanned.length if scanned
|
1046
1037
|
media_parser = Sass::SCSS::Parser.new(scanner,
|
1047
1038
|
@options[:filename], @options[:importer], @line, offset)
|
1048
1039
|
media = media_parser.parse_media_query_list
|
1049
|
-
node = Tree::CssImportNode.new(
|
1040
|
+
node = Tree::CssImportNode.new(quoted_val, media.to_a)
|
1050
1041
|
node.source_range = Sass::Source::Range.new(
|
1051
1042
|
Sass::Source::Position.new(@line, to_parser_offset(start_offset)),
|
1052
1043
|
Sass::Source::Position.new(@line, media_parser.offset),
|
1053
1044
|
@options[:filename], @options[:importer])
|
1054
1045
|
elsif val =~ %r{^(https?:)?//}
|
1055
|
-
node = Tree::CssImportNode.new(
|
1046
|
+
node = Tree::CssImportNode.new(quoted_val)
|
1056
1047
|
node.source_range = Sass::Source::Range.new(
|
1057
1048
|
Sass::Source::Position.new(@line, to_parser_offset(start_offset)),
|
1058
1049
|
Sass::Source::Position.new(@line, to_parser_offset(offset)),
|
data/lib/sass/environment.rb
CHANGED
@@ -41,7 +41,7 @@ module Sass
|
|
41
41
|
if @#{name}s.include?(name)
|
42
42
|
@#{name}s[name] = value
|
43
43
|
true
|
44
|
-
elsif @parent
|
44
|
+
elsif @parent && !@parent.global?
|
45
45
|
@parent.try_set_#{name}(name, value)
|
46
46
|
else
|
47
47
|
false
|
@@ -53,6 +53,10 @@ module Sass
|
|
53
53
|
@#{name}s ||= {}
|
54
54
|
@#{name}s[name.tr('_', '-')] = value
|
55
55
|
end
|
56
|
+
|
57
|
+
def set_global_#{name}(name, value)
|
58
|
+
global_env.set_#{name}(name, value)
|
59
|
+
end
|
56
60
|
RUBY
|
57
61
|
end
|
58
62
|
end
|
@@ -76,19 +80,6 @@ module Sass
|
|
76
80
|
# Sass::Callable
|
77
81
|
inherited_hash_reader :function
|
78
82
|
|
79
|
-
# Whether a warning has been emitted for assigning to the given
|
80
|
-
# global variable. This is a set of tuples containing the name of
|
81
|
-
# the variable, its filename, and its line number.
|
82
|
-
#
|
83
|
-
# @return [Set<[String, String, int]>]
|
84
|
-
attr_reader :global_warning_given
|
85
|
-
|
86
|
-
# Whether a warning has been emitted for misusing a deprecated false value.
|
87
|
-
# This is a set of tuples containing the filename and its line number.
|
88
|
-
#
|
89
|
-
# @return [Set<[String, int]>]
|
90
|
-
attr_reader :deprecated_false_warning_given
|
91
|
-
|
92
83
|
# @param options [{Symbol => Object}] The options hash. See
|
93
84
|
# {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
|
94
85
|
# @param parent [Environment] See \{#parent}
|
@@ -96,8 +87,13 @@ module Sass
|
|
96
87
|
@parent = parent
|
97
88
|
@options = options || (parent && parent.options) || {}
|
98
89
|
@stack = Sass::Stack.new if @parent.nil?
|
99
|
-
|
100
|
-
|
90
|
+
end
|
91
|
+
|
92
|
+
# Returns whether this is the global environment.
|
93
|
+
#
|
94
|
+
# @return [Boolean]
|
95
|
+
def global?
|
96
|
+
@parent.nil?
|
101
97
|
end
|
102
98
|
|
103
99
|
# The environment of the caller of this environment's mixin or function.
|
@@ -128,7 +124,7 @@ module Sass
|
|
128
124
|
#
|
129
125
|
# @return [Environment]
|
130
126
|
def global_env
|
131
|
-
@global_env ||=
|
127
|
+
@global_env ||= global? ? self : @parent.global_env
|
132
128
|
end
|
133
129
|
|
134
130
|
# The import/mixin stack.
|
data/lib/sass/error.rb
CHANGED
@@ -140,8 +140,8 @@ module Sass
|
|
140
140
|
def sass_backtrace_str(default_filename = "an unknown file")
|
141
141
|
lines = message.split("\n")
|
142
142
|
msg = lines[0] + lines[1..-1].
|
143
|
-
map {|l| "\n" + (" " * "
|
144
|
-
"
|
143
|
+
map {|l| "\n" + (" " * "Error: ".size) + l}.join
|
144
|
+
"Error: #{msg}" +
|
145
145
|
Sass::Util.enum_with_index(sass_backtrace).map do |entry, i|
|
146
146
|
"\n #{i == 0 ? "on" : "from"} line #{entry[:line]}" +
|
147
147
|
" of #{entry[:filename] || default_filename}" +
|
@@ -153,15 +153,13 @@ module Sass
|
|
153
153
|
# Returns an error report for an exception in CSS format.
|
154
154
|
#
|
155
155
|
# @param e [Exception]
|
156
|
-
# @param
|
156
|
+
# @param line_offset [Fixnum] The number of the first line of the Sass template.
|
157
157
|
# @return [String] The error report
|
158
158
|
# @raise [Exception] `e`, if the
|
159
159
|
# {file:SASS_REFERENCE.md#full_exception-option `:full_exception`} option
|
160
160
|
# is set to false.
|
161
|
-
def exception_to_css(e,
|
162
|
-
|
163
|
-
|
164
|
-
header = header_string(e, options)
|
161
|
+
def exception_to_css(e, line_offset = 1)
|
162
|
+
header = header_string(e, line_offset)
|
165
163
|
|
166
164
|
<<END
|
167
165
|
/*
|
@@ -178,12 +176,11 @@ END
|
|
178
176
|
|
179
177
|
private
|
180
178
|
|
181
|
-
def header_string(e,
|
179
|
+
def header_string(e, line_offset)
|
182
180
|
unless e.is_a?(Sass::SyntaxError) && e.sass_line && e.sass_template
|
183
181
|
return "#{e.class}: #{e.message}"
|
184
182
|
end
|
185
183
|
|
186
|
-
line_offset = options[:line] || 1
|
187
184
|
line_num = e.sass_line + 1 - line_offset
|
188
185
|
min = [line_num - 6, 0].max
|
189
186
|
section = e.sass_template.rstrip.split("\n")[min ... line_num + 5]
|