mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Changing the text for Sass indentation errors.
This commit is contained in:
parent
2629f908a5
commit
8ed3ddeb81
2 changed files with 19 additions and 14 deletions
|
@ -147,7 +147,7 @@ module Sass
|
||||||
|
|
||||||
if tabs # if line isn't blank
|
if tabs # if line isn't blank
|
||||||
if tabs - old_tabs > 1
|
if tabs - old_tabs > 1
|
||||||
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.", @line)
|
raise SyntaxError.new("#{tabs * 2} spaces were used for indentation. Sass must be indented using two spaces.", @line)
|
||||||
end
|
end
|
||||||
@lines << [line.strip, tabs]
|
@lines << [line.strip, tabs]
|
||||||
|
|
||||||
|
@ -162,18 +162,20 @@ module Sass
|
||||||
|
|
||||||
# Counts the tabulation of a line.
|
# Counts the tabulation of a line.
|
||||||
def count_tabs(line)
|
def count_tabs(line)
|
||||||
spaces = line.index(/[^ ]/)
|
return nil if line.strip.empty?
|
||||||
if spaces
|
return nil unless spaces = line.index(/[^ ]/)
|
||||||
if spaces % 2 == 1 || line[spaces] == ?\t
|
|
||||||
# Make sure a line with just tabs isn't an error
|
|
||||||
return nil if line.strip.empty?
|
|
||||||
|
|
||||||
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.", @line)
|
if spaces % 2 == 1
|
||||||
end
|
raise SyntaxError.new(<<END.strip, @line)
|
||||||
spaces / 2
|
#{spaces} space#{spaces == 1 ? ' was' : 's were'} used for indentation. Sass must be indented using two spaces.
|
||||||
else
|
END
|
||||||
nil
|
elsif line[spaces] == ?\t
|
||||||
|
raise SyntaxError.new(<<END.strip, @line)
|
||||||
|
A tab character was used for indentation. Sass must be indented using two spaces.
|
||||||
|
Are you sure you have soft tabs enabled in your editor?
|
||||||
|
END
|
||||||
end
|
end
|
||||||
|
spaces / 2
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_tree(index)
|
def build_tree(index)
|
||||||
|
|
|
@ -32,9 +32,12 @@ class SassEngineTest < Test::Unit::TestCase
|
||||||
"!a" => 'Invalid constant: "!a"',
|
"!a" => 'Invalid constant: "!a"',
|
||||||
"! a" => 'Invalid constant: "! a"',
|
"! a" => 'Invalid constant: "! a"',
|
||||||
"!a b" => 'Invalid constant: "!a b"',
|
"!a b" => 'Invalid constant: "!a b"',
|
||||||
"a\n\t:b c" => "Illegal Indentation: Only two space characters are allowed as tabulation.",
|
"a\n\t:b c" => <<END.strip,
|
||||||
"a\n :b c" => "Illegal Indentation: Only two space characters are allowed as tabulation.",
|
A tab character was used for indentation. Sass must be indented using two spaces.
|
||||||
"a\n :b c" => "Illegal Indentation: Only two space characters are allowed as tabulation.",
|
Are you sure you have soft tabs enabled in your editor?
|
||||||
|
END
|
||||||
|
"a\n :b c" => "1 space was used for indentation. Sass must be indented using two spaces.",
|
||||||
|
"a\n :b c" => "4 spaces were used for indentation. Sass must be indented using two spaces.",
|
||||||
"a\n :b c\n !d = 3" => "Constants may only be declared at the root of a document.",
|
"a\n :b c\n !d = 3" => "Constants may only be declared at the root of a document.",
|
||||||
"!a = 1b + 2c" => "Incompatible units: b and c",
|
"!a = 1b + 2c" => "Incompatible units: b and c",
|
||||||
"& a\n :b c" => "Base-level rules cannot contain the parent-selector-referencing character '&'",
|
"& a\n :b c" => "Base-level rules cannot contain the parent-selector-referencing character '&'",
|
||||||
|
|
Loading…
Add table
Reference in a new issue