sass 3.3.0.alpha.256 → 3.3.0.alpha.353
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/REVISION +1 -1
- data/Rakefile +21 -1
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/lib/sass.rb +6 -3
- data/lib/sass/cache_stores/base.rb +1 -1
- data/lib/sass/cache_stores/chain.rb +2 -1
- data/lib/sass/cache_stores/filesystem.rb +2 -6
- data/lib/sass/cache_stores/memory.rb +1 -1
- data/lib/sass/cache_stores/null.rb +2 -2
- data/lib/sass/callbacks.rb +1 -0
- data/lib/sass/css.rb +6 -6
- data/lib/sass/engine.rb +60 -34
- data/lib/sass/environment.rb +3 -1
- data/lib/sass/error.rb +5 -5
- data/lib/sass/exec.rb +52 -25
- data/lib/sass/features.rb +0 -2
- data/lib/sass/importers/deprecated_path.rb +1 -1
- data/lib/sass/importers/filesystem.rb +8 -6
- data/lib/sass/logger/base.rb +3 -3
- data/lib/sass/logger/log_level.rb +4 -6
- data/lib/sass/media.rb +2 -2
- data/lib/sass/plugin.rb +4 -2
- data/lib/sass/plugin/compiler.rb +28 -15
- data/lib/sass/plugin/configuration.rb +15 -7
- data/lib/sass/plugin/merb.rb +1 -1
- data/lib/sass/plugin/staleness_checker.rb +24 -8
- data/lib/sass/repl.rb +3 -3
- data/lib/sass/script.rb +2 -1
- data/lib/sass/script/css_lexer.rb +8 -3
- data/lib/sass/script/css_parser.rb +6 -2
- data/lib/sass/script/functions.rb +164 -109
- data/lib/sass/script/lexer.rb +30 -20
- data/lib/sass/script/parser.rb +66 -37
- data/lib/sass/script/tree/funcall.rb +23 -14
- data/lib/sass/script/tree/interpolation.rb +5 -1
- data/lib/sass/script/tree/list_literal.rb +5 -4
- data/lib/sass/script/tree/map_literal.rb +1 -1
- data/lib/sass/script/tree/node.rb +2 -2
- data/lib/sass/script/tree/operation.rb +2 -1
- data/lib/sass/script/tree/selector.rb +3 -2
- data/lib/sass/script/tree/string_interpolation.rb +2 -1
- data/lib/sass/script/tree/variable.rb +4 -3
- data/lib/sass/script/value/base.rb +12 -14
- data/lib/sass/script/value/color.rb +35 -16
- data/lib/sass/script/value/helpers.rb +146 -0
- data/lib/sass/script/value/list.rb +24 -5
- data/lib/sass/script/value/map.rb +1 -1
- data/lib/sass/script/value/null.rb +13 -3
- data/lib/sass/script/value/number.rb +44 -35
- data/lib/sass/script/value/string.rb +2 -2
- data/lib/sass/scss/css_parser.rb +2 -1
- data/lib/sass/scss/parser.rb +143 -93
- data/lib/sass/scss/rx.rb +4 -4
- data/lib/sass/scss/script_lexer.rb +1 -0
- data/lib/sass/scss/script_parser.rb +1 -0
- data/lib/sass/scss/static_parser.rb +5 -5
- data/lib/sass/selector.rb +5 -2
- data/lib/sass/selector/abstract_sequence.rb +1 -1
- data/lib/sass/selector/comma_sequence.rb +16 -14
- data/lib/sass/selector/sequence.rb +38 -24
- data/lib/sass/selector/simple.rb +4 -4
- data/lib/sass/selector/simple_sequence.rb +21 -11
- data/lib/sass/source/map.rb +7 -2
- data/lib/sass/source/range.rb +1 -1
- data/lib/sass/supports.rb +3 -3
- data/lib/sass/tree/debug_node.rb +1 -1
- data/lib/sass/tree/function_node.rb +2 -1
- data/lib/sass/tree/if_node.rb +1 -1
- data/lib/sass/tree/import_node.rb +3 -4
- data/lib/sass/tree/prop_node.rb +4 -2
- data/lib/sass/tree/rule_node.rb +5 -2
- data/lib/sass/tree/visitors/base.rb +6 -6
- data/lib/sass/tree/visitors/check_nesting.rb +12 -9
- data/lib/sass/tree/visitors/convert.rb +34 -28
- data/lib/sass/tree/visitors/cssize.rb +4 -3
- data/lib/sass/tree/visitors/deep_copy.rb +1 -0
- data/lib/sass/tree/visitors/perform.rb +31 -16
- data/lib/sass/tree/visitors/to_css.rb +34 -16
- data/lib/sass/util.rb +88 -37
- data/lib/sass/util/multibyte_string_scanner.rb +2 -0
- data/lib/sass/util/ordered_hash.rb +20 -18
- data/lib/sass/util/subset_map.rb +3 -2
- data/lib/sass/util/test.rb +0 -1
- data/lib/sass/version.rb +9 -5
- data/test/rubocop_extensions.rb +70 -0
- data/test/sass/functions_test.rb +20 -1
- data/test/sass/importer_test.rb +2 -1
- data/test/sass/script_test.rb +4 -0
- data/test/sass/source_map_test.rb +1 -1
- data/test/sass/util_test.rb +49 -0
- data/test/sass/value_helpers_test.rb +181 -0
- metadata +13 -9
data/REVISION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
da2d3e225bd2eb195eef404a6dc5ae48e51b1fdc
|
data/Rakefile
CHANGED
|
@@ -19,6 +19,26 @@ Rake::TestTask.new do |t|
|
|
|
19
19
|
t.verbose = true
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
# ----- Code Style Enforcement -----
|
|
23
|
+
|
|
24
|
+
if RUBY_VERSION !~ /^(1\.8|2\.1)/ && (ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] == "true" || !ENV.has_key?("RUBOCOP"))
|
|
25
|
+
require 'rubocop/rake_task'
|
|
26
|
+
require "#{File.dirname(__FILE__)}/test/rubocop_extensions.rb"
|
|
27
|
+
Rubocop::RakeTask.new do |t|
|
|
28
|
+
t.patterns = FileList["lib/**/*"]
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
task :rubocop do
|
|
32
|
+
puts "Skipping rubocop style check."
|
|
33
|
+
if !ENV.has_key?("RUBOCOP")
|
|
34
|
+
puts "Passing this check is required in order for your patch to be accepted."
|
|
35
|
+
puts "Use ruby 1.9 or greater and then run the style check with: rake rubocop"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
task :test => :rubocop
|
|
41
|
+
|
|
22
42
|
# ----- Packaging -----
|
|
23
43
|
|
|
24
44
|
# Don't use Rake::GemPackageTast because we want prerequisites to run
|
|
@@ -191,7 +211,7 @@ begin
|
|
|
191
211
|
task :undocumented do
|
|
192
212
|
opts = ENV["YARD_OPTS"] || ""
|
|
193
213
|
ENV["YARD_OPTS"] = opts.dup + <<OPTS
|
|
194
|
-
--list --query "
|
|
214
|
+
--list --tag comment --hide-tag comment --query "
|
|
195
215
|
object.docstring.blank? &&
|
|
196
216
|
!(object.type == :method && object.is_alias?)"
|
|
197
217
|
OPTS
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.3.0.alpha.
|
|
1
|
+
3.3.0.alpha.353
|
data/VERSION_DATE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
04 October 2013 22:23:30 GMT
|
data/lib/sass.rb
CHANGED
|
@@ -35,8 +35,11 @@ module Sass
|
|
|
35
35
|
# Sass.load_paths << File.dirname(__FILE__ + '/sass')
|
|
36
36
|
# @return [Array<String, Pathname, Sass::Importers::Base>]
|
|
37
37
|
def self.load_paths
|
|
38
|
-
@load_paths ||= ENV['SASS_PATH']
|
|
39
|
-
|
|
38
|
+
@load_paths ||= if ENV['SASS_PATH']
|
|
39
|
+
ENV['SASS_PATH'].split(Sass::Util.windows? ? ';' : ':')
|
|
40
|
+
else
|
|
41
|
+
[]
|
|
42
|
+
end
|
|
40
43
|
end
|
|
41
44
|
|
|
42
45
|
# Compile a Sass or SCSS string to CSS.
|
|
@@ -82,7 +85,7 @@ module Sass
|
|
|
82
85
|
result = Sass::Engine.for_file(filename, options).render
|
|
83
86
|
if css_filename
|
|
84
87
|
options[:css_filename] ||= css_filename
|
|
85
|
-
open(css_filename,"w") {|css_file| css_file.write(result)}
|
|
88
|
+
open(css_filename, "w") {|css_file| css_file.write(result)}
|
|
86
89
|
nil
|
|
87
90
|
else
|
|
88
91
|
result
|
|
@@ -22,7 +22,8 @@ module Sass
|
|
|
22
22
|
# @see Base#retrieve
|
|
23
23
|
def retrieve(key, sha)
|
|
24
24
|
@caches.each_with_index do |c, i|
|
|
25
|
-
|
|
25
|
+
obj = c.retrieve(key, sha)
|
|
26
|
+
next unless obj
|
|
26
27
|
@caches[0...i].each {|prev| prev.store(key, sha, obj)}
|
|
27
28
|
return obj
|
|
28
29
|
end
|
|
@@ -30,19 +30,15 @@ module Sass
|
|
|
30
30
|
|
|
31
31
|
# @see Base#\_store
|
|
32
32
|
def _store(key, version, sha, contents)
|
|
33
|
-
# return unless File.writable?(File.dirname(@cache_location))
|
|
34
|
-
# return if File.exists?(@cache_location) && !File.writable?(@cache_location)
|
|
35
33
|
compiled_filename = path_to(key)
|
|
36
|
-
# return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
|
|
37
|
-
# return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
|
|
38
34
|
FileUtils.mkdir_p(File.dirname(compiled_filename))
|
|
39
|
-
|
|
35
|
+
Sass::Util.atomic_create_and_write_file(compiled_filename) do |f|
|
|
40
36
|
f.puts(version)
|
|
41
37
|
f.puts(sha)
|
|
42
38
|
f.write(contents)
|
|
43
39
|
end
|
|
44
40
|
rescue Errno::EACCES
|
|
45
|
-
#pass
|
|
41
|
+
# pass
|
|
46
42
|
end
|
|
47
43
|
|
|
48
44
|
private
|
data/lib/sass/callbacks.rb
CHANGED
data/lib/sass/css.rb
CHANGED
|
@@ -169,11 +169,11 @@ module Sass
|
|
|
169
169
|
current_rule.parsed_rules = make_seq(first)
|
|
170
170
|
end
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
if rest.empty?
|
|
173
|
+
current_rule.children += child.children
|
|
174
|
+
else
|
|
173
175
|
child.parsed_rules = make_seq(*rest)
|
|
174
176
|
current_rule << child
|
|
175
|
-
else
|
|
176
|
-
current_rule.children += child.children
|
|
177
177
|
end
|
|
178
178
|
|
|
179
179
|
current_rule
|
|
@@ -220,12 +220,12 @@ module Sass
|
|
|
220
220
|
current_rule.parsed_rules = make_sseq(last_simple_subject, *firsts)
|
|
221
221
|
end
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
if rest.empty?
|
|
224
|
+
current_rule.children += child.children
|
|
225
|
+
else
|
|
224
226
|
rest.unshift Sass::Selector::Parent.new
|
|
225
227
|
child.parsed_rules = make_sseq(sseq.subject?, *rest)
|
|
226
228
|
current_rule << child
|
|
227
|
-
else
|
|
228
|
-
current_rule.children += child.children
|
|
229
229
|
end
|
|
230
230
|
|
|
231
231
|
current_rule
|
data/lib/sass/engine.rb
CHANGED
|
@@ -196,9 +196,11 @@ module Sass
|
|
|
196
196
|
# Remove any deprecated importers if the location is imported explicitly
|
|
197
197
|
options[:load_paths].reject! do |importer|
|
|
198
198
|
importer.is_a?(Sass::Importers::DeprecatedPath) &&
|
|
199
|
-
options[:load_paths].find
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
options[:load_paths].find do |other_importer|
|
|
200
|
+
other_importer.is_a?(Sass::Importers::Filesystem) &&
|
|
201
|
+
other_importer != importer &&
|
|
202
|
+
other_importer.root == importer.root
|
|
203
|
+
end
|
|
202
204
|
end
|
|
203
205
|
|
|
204
206
|
# Backwards compatibility
|
|
@@ -259,7 +261,7 @@ module Sass
|
|
|
259
261
|
# See {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
|
|
260
262
|
# @see {Sass::Engine.for_file}
|
|
261
263
|
# @see {Sass::Plugin}
|
|
262
|
-
def initialize(template, options={})
|
|
264
|
+
def initialize(template, options = {})
|
|
263
265
|
@options = self.class.normalize_options(options)
|
|
264
266
|
@template = template
|
|
265
267
|
end
|
|
@@ -300,9 +302,11 @@ module Sass
|
|
|
300
302
|
# @return [Sass::Tree::Node] The root of the parse tree.
|
|
301
303
|
# @raise [Sass::SyntaxError] if there's an error in the document
|
|
302
304
|
def to_tree
|
|
303
|
-
@tree ||= @options[:quiet]
|
|
304
|
-
|
|
305
|
-
|
|
305
|
+
@tree ||= if @options[:quiet]
|
|
306
|
+
Sass::Util.silence_sass_warnings {_to_tree}
|
|
307
|
+
else
|
|
308
|
+
_to_tree
|
|
309
|
+
end
|
|
306
310
|
end
|
|
307
311
|
|
|
308
312
|
# Returns the original encoding of the document,
|
|
@@ -331,7 +335,8 @@ module Sass
|
|
|
331
335
|
#
|
|
332
336
|
# @private
|
|
333
337
|
def _dependencies(seen, engines)
|
|
334
|
-
|
|
338
|
+
key = [@options[:filename], @options[:importer]]
|
|
339
|
+
return if seen.include?(key)
|
|
335
340
|
seen << key
|
|
336
341
|
engines << self
|
|
337
342
|
to_tree.grep(Tree::ImportNode) do |n|
|
|
@@ -387,7 +392,7 @@ ERR
|
|
|
387
392
|
key = sassc_key
|
|
388
393
|
sha = Digest::SHA1.hexdigest(@template)
|
|
389
394
|
|
|
390
|
-
if root = @options[:cache_store].retrieve(key, sha)
|
|
395
|
+
if (root = @options[:cache_store].retrieve(key, sha))
|
|
391
396
|
root.options = @options
|
|
392
397
|
return root
|
|
393
398
|
end
|
|
@@ -486,7 +491,10 @@ END
|
|
|
486
491
|
lines
|
|
487
492
|
end
|
|
488
493
|
|
|
494
|
+
# @comment
|
|
495
|
+
# rubocop:disable ParameterLists
|
|
489
496
|
def try_comment(line, last, tab_str, comment_tab_str, index)
|
|
497
|
+
# rubocop:enable ParameterLists
|
|
490
498
|
return unless last && last.comment?
|
|
491
499
|
# Nested comment stuff must be at least one whitespace char deeper
|
|
492
500
|
# than the normal indentation
|
|
@@ -511,7 +519,8 @@ MSG
|
|
|
511
519
|
nodes = []
|
|
512
520
|
while (line = arr[i]) && line.tabs >= base
|
|
513
521
|
if line.tabs > base
|
|
514
|
-
raise SyntaxError.new(
|
|
522
|
+
raise SyntaxError.new(
|
|
523
|
+
"The line was indented #{line.tabs - base} levels deeper than the previous line.",
|
|
515
524
|
:line => line.index) if line.tabs > base + 1
|
|
516
525
|
|
|
517
526
|
nodes.last.children, i = tree(arr, i)
|
|
@@ -617,7 +626,7 @@ WARNING
|
|
|
617
626
|
:line => @line) if name.nil? || value.nil?
|
|
618
627
|
|
|
619
628
|
value_start_offset = name_end_offset = name_start_offset + name.length
|
|
620
|
-
|
|
629
|
+
unless value.empty?
|
|
621
630
|
# +1 and -1 both compensate for the leading ':', which is part of line.text
|
|
622
631
|
value_start_offset = name_start_offset + line.text.index(value, name.length + 1) - 1
|
|
623
632
|
end
|
|
@@ -659,7 +668,7 @@ WARNING
|
|
|
659
668
|
@options[:filename], @options[:importer],
|
|
660
669
|
@line, to_parser_offset(offset))
|
|
661
670
|
|
|
662
|
-
unless res = parser.parse_interp_ident
|
|
671
|
+
unless (res = parser.parse_interp_ident)
|
|
663
672
|
parsed = parse_interp(line.text, line.offset)
|
|
664
673
|
return Tree::RuleNode.new(parsed, full_line_range(line))
|
|
665
674
|
end
|
|
@@ -672,13 +681,13 @@ WARNING
|
|
|
672
681
|
res.unshift(hack_char) if hack_char
|
|
673
682
|
|
|
674
683
|
# Handle comments after a property name but before the colon.
|
|
675
|
-
if comment = scanner.scan(Sass::SCSS::RX::COMMENT)
|
|
684
|
+
if (comment = scanner.scan(Sass::SCSS::RX::COMMENT))
|
|
676
685
|
res << comment
|
|
677
686
|
offset += comment.length
|
|
678
687
|
end
|
|
679
688
|
|
|
680
689
|
name = line.text[0...scanner.pos]
|
|
681
|
-
if scanned = scanner.scan(/\s*:(?:\s+|$)/) # test for a property
|
|
690
|
+
if (scanned = scanner.scan(/\s*:(?:\s+|$)/)) # test for a property
|
|
682
691
|
offset += scanned.length
|
|
683
692
|
property = parse_property(name, res, scanner.rest, :new, line, offset)
|
|
684
693
|
property.name_source_range = ident_range
|
|
@@ -686,9 +695,8 @@ WARNING
|
|
|
686
695
|
else
|
|
687
696
|
res.pop if comment
|
|
688
697
|
|
|
689
|
-
if trailing = (scanner.scan(/\s*#{Sass::SCSS::RX::COMMENT}/) ||
|
|
690
|
-
|
|
691
|
-
offset += trailing.length # skip over comment for rule processing
|
|
698
|
+
if (trailing = (scanner.scan(/\s*#{Sass::SCSS::RX::COMMENT}/) ||
|
|
699
|
+
scanner.scan(/\s*#{Sass::SCSS::RX::SINGLE_LINE_COMMENT}/)))
|
|
692
700
|
trailing.strip!
|
|
693
701
|
end
|
|
694
702
|
interp_parsed = parse_interp(scanner.rest)
|
|
@@ -702,7 +710,10 @@ WARNING
|
|
|
702
710
|
end
|
|
703
711
|
end
|
|
704
712
|
|
|
713
|
+
# @comment
|
|
714
|
+
# rubocop:disable ParameterLists
|
|
705
715
|
def parse_property(name, parsed_name, value, prop, line, start_offset)
|
|
716
|
+
# rubocop:enable ParameterLists
|
|
706
717
|
if value.strip.empty?
|
|
707
718
|
expr = Sass::Script::Tree::Literal.new(Sass::Script::Value::String.new(""))
|
|
708
719
|
end_offset = start_offset
|
|
@@ -755,7 +766,13 @@ WARNING
|
|
|
755
766
|
str = str.gsub(/^#{line.comment_tab_str}/m, '')[2..-1] # get rid of // or /*
|
|
756
767
|
format_comment_text(str, silent)
|
|
757
768
|
end
|
|
758
|
-
type = if silent
|
|
769
|
+
type = if silent
|
|
770
|
+
:silent
|
|
771
|
+
elsif loud
|
|
772
|
+
:loud
|
|
773
|
+
else
|
|
774
|
+
:normal
|
|
775
|
+
end
|
|
759
776
|
Tree::CommentNode.new(value, type)
|
|
760
777
|
else
|
|
761
778
|
Tree::RuleNode.new(parse_interp(line.text), full_line_range(line))
|
|
@@ -766,6 +783,8 @@ WARNING
|
|
|
766
783
|
:each, :while, :if, :else, :extend, :import, :media, :charset, :content,
|
|
767
784
|
:at_root]
|
|
768
785
|
|
|
786
|
+
# @comment
|
|
787
|
+
# rubocop:disable MethodLength
|
|
769
788
|
def parse_directive(parent, line, root)
|
|
770
789
|
directive, whitespace, value = line.text[1..-1].split(/(\s+)/, 2)
|
|
771
790
|
offset = directive.size + whitespace.size + 1 if whitespace
|
|
@@ -781,7 +800,7 @@ WARNING
|
|
|
781
800
|
return Tree::SupportsNode.new(directive, parser.parse_supports_condition)
|
|
782
801
|
end
|
|
783
802
|
|
|
784
|
-
|
|
803
|
+
Tree::DirectiveNode.new(
|
|
785
804
|
value.nil? ? ["@#{directive}"] : ["@#{directive} "] + parse_interp(value, offset))
|
|
786
805
|
end
|
|
787
806
|
|
|
@@ -817,6 +836,8 @@ WARNING
|
|
|
817
836
|
)
|
|
818
837
|
Tree::ExtendNode.new(interp_parsed, optional, selector_range)
|
|
819
838
|
end
|
|
839
|
+
# @comment
|
|
840
|
+
# rubocop:enable MethodLength
|
|
820
841
|
|
|
821
842
|
def parse_warn_directive(parent, line, root, value, offset)
|
|
822
843
|
raise SyntaxError.new("Invalid warn directive '@warn': expected expression.") unless value
|
|
@@ -835,7 +856,7 @@ WARNING
|
|
|
835
856
|
end
|
|
836
857
|
|
|
837
858
|
def parse_charset_directive(parent, line, root, value, offset)
|
|
838
|
-
name = value && value[/\A(["'])(.*)\1\Z/, 2] #"
|
|
859
|
+
name = value && value[/\A(["'])(.*)\1\Z/, 2] # "
|
|
839
860
|
raise SyntaxError.new("Invalid charset directive '@charset': expected string.") unless name
|
|
840
861
|
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath charset directives.",
|
|
841
862
|
:line => @line + 1) unless line.children.empty?
|
|
@@ -861,10 +882,6 @@ WARNING
|
|
|
861
882
|
return at_root_node unless value
|
|
862
883
|
|
|
863
884
|
parsed = parse_interp(value, offset)
|
|
864
|
-
selector_range = Sass::Source::Range.new(
|
|
865
|
-
Sass::Source::Position.new(@line, to_parser_offset(offset)),
|
|
866
|
-
Sass::Source::Position.new(@line, to_parser_offset(line.offset) + line.text.length),
|
|
867
|
-
@options[:filename], @options[:importer])
|
|
868
885
|
rule_node = Tree::RuleNode.new(parsed, full_line_range(line))
|
|
869
886
|
|
|
870
887
|
# The caller expects to automatically add children to the returned node
|
|
@@ -878,7 +895,8 @@ WARNING
|
|
|
878
895
|
end
|
|
879
896
|
|
|
880
897
|
def parse_for_directive(parent, line, root, value, offset)
|
|
881
|
-
var, from_expr, to_name, to_expr =
|
|
898
|
+
var, from_expr, to_name, to_expr =
|
|
899
|
+
value.scan(/^([^\s]+)\s+from\s+(.+)\s+(to|through)\s+(.+)$/).first
|
|
882
900
|
|
|
883
901
|
if var.nil? # scan failed, try to figure out why for error message
|
|
884
902
|
if value !~ /^[^\s]+/
|
|
@@ -945,8 +963,9 @@ WARNING
|
|
|
945
963
|
values = []
|
|
946
964
|
|
|
947
965
|
loop do
|
|
948
|
-
unless node = parse_import_arg(scanner, offset + scanner.pos)
|
|
949
|
-
raise SyntaxError.new(
|
|
966
|
+
unless (node = parse_import_arg(scanner, offset + scanner.pos))
|
|
967
|
+
raise SyntaxError.new(
|
|
968
|
+
"Invalid @import: expected file to import, was #{scanner.rest.inspect}",
|
|
950
969
|
:line => @line)
|
|
951
970
|
end
|
|
952
971
|
values << node
|
|
@@ -958,9 +977,11 @@ WARNING
|
|
|
958
977
|
:line => @line)
|
|
959
978
|
end
|
|
960
979
|
|
|
961
|
-
|
|
980
|
+
values
|
|
962
981
|
end
|
|
963
982
|
|
|
983
|
+
# @comment
|
|
984
|
+
# rubocop:disable MethodLength
|
|
964
985
|
def parse_import_arg(scanner, offset)
|
|
965
986
|
return if scanner.eos?
|
|
966
987
|
|
|
@@ -971,7 +992,7 @@ WARNING
|
|
|
971
992
|
media_parser = Sass::SCSS::Parser.new(scanner,
|
|
972
993
|
@options[:filename], @options[:importer],
|
|
973
994
|
@line, str.source_range.end_pos.offset)
|
|
974
|
-
if media = media_parser.parse_media_query_list
|
|
995
|
+
if (media = media_parser.parse_media_query_list)
|
|
975
996
|
end_pos = Sass::Source::Position.new(@line, media_parser.offset + 1)
|
|
976
997
|
node = Tree::CssImportNode.new(str, media.to_a)
|
|
977
998
|
else
|
|
@@ -985,7 +1006,7 @@ WARNING
|
|
|
985
1006
|
return node
|
|
986
1007
|
end
|
|
987
1008
|
|
|
988
|
-
unless str = scanner.scan(Sass::SCSS::RX::STRING)
|
|
1009
|
+
unless (str = scanner.scan(Sass::SCSS::RX::STRING))
|
|
989
1010
|
scanned = scanner.scan(/[^,;]+/)
|
|
990
1011
|
node = Tree::ImportNode.new(scanned)
|
|
991
1012
|
start_parser_offset = to_parser_offset(offset)
|
|
@@ -1010,7 +1031,7 @@ WARNING
|
|
|
1010
1031
|
Sass::Source::Position.new(@line, to_parser_offset(start_offset)),
|
|
1011
1032
|
Sass::Source::Position.new(@line, media_parser.offset),
|
|
1012
1033
|
@options[:filename], @options[:importer])
|
|
1013
|
-
elsif val =~
|
|
1034
|
+
elsif val =~ %r{^(https?:)?//}
|
|
1014
1035
|
node = Tree::CssImportNode.new("url(#{val})")
|
|
1015
1036
|
node.source_range = Sass::Source::Range.new(
|
|
1016
1037
|
Sass::Source::Position.new(@line, to_parser_offset(start_offset)),
|
|
@@ -1025,6 +1046,8 @@ WARNING
|
|
|
1025
1046
|
end
|
|
1026
1047
|
node
|
|
1027
1048
|
end
|
|
1049
|
+
# @comment
|
|
1050
|
+
# rubocop:enable MethodLength
|
|
1028
1051
|
|
|
1029
1052
|
def parse_mixin_directive(parent, line, root, value, offset)
|
|
1030
1053
|
parse_mixin_definition(line)
|
|
@@ -1044,7 +1067,10 @@ WARNING
|
|
|
1044
1067
|
CONTENT_RE = /^@content\s*(.+)?$/
|
|
1045
1068
|
def parse_content_directive(parent, line, root, value, offset)
|
|
1046
1069
|
trailing = line.text.scan(CONTENT_RE).first.first
|
|
1047
|
-
|
|
1070
|
+
unless trailing.nil?
|
|
1071
|
+
raise SyntaxError.new(
|
|
1072
|
+
"Invalid content directive. Trailing characters found: \"#{trailing}\".")
|
|
1073
|
+
end
|
|
1048
1074
|
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath @content directives.",
|
|
1049
1075
|
:line => line.index + 1) unless line.children.empty?
|
|
1050
1076
|
Tree::ContentNode.new
|
|
@@ -1092,7 +1118,7 @@ WARNING
|
|
|
1092
1118
|
end
|
|
1093
1119
|
|
|
1094
1120
|
return silent ? "//" : "/* */" if content.empty?
|
|
1095
|
-
content.last.gsub!(
|
|
1121
|
+
content.last.gsub!(/ ?\*\/ *$/, '')
|
|
1096
1122
|
content.map! {|l| l.gsub!(/^\*( ?)/, '\1') || (l.empty? ? "" : " ") + l}
|
|
1097
1123
|
content.first.gsub!(/^ /, '') unless removed_first
|
|
1098
1124
|
if silent
|
|
@@ -1128,7 +1154,7 @@ WARNING
|
|
|
1128
1154
|
rest = Sass::Shared.handle_interpolation text do |scan|
|
|
1129
1155
|
escapes = scan[2].size
|
|
1130
1156
|
res << scan.matched[0...-2 - escapes]
|
|
1131
|
-
if escapes
|
|
1157
|
+
if escapes.odd?
|
|
1132
1158
|
res << "\\" * (escapes - 1) << '#{'
|
|
1133
1159
|
else
|
|
1134
1160
|
res << "\\" * [0, escapes - 1].max
|