mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Errors thrown for improper tabulation.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@314 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
9846d89754
commit
81cf2f5e8e
2 changed files with 15 additions and 1 deletions
|
@ -201,14 +201,24 @@ module Haml
|
|||
|
||||
if !suppress_render
|
||||
line_empty = old_line.empty?
|
||||
|
||||
process_indent(old_tabs, old_line) unless line_empty
|
||||
flat = @flat_spaces != -1
|
||||
|
||||
|
||||
if !flat && old_spaces != old_tabs * 2
|
||||
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.")
|
||||
end
|
||||
|
||||
if flat
|
||||
push_flat(old_line, old_spaces)
|
||||
elsif !line_empty
|
||||
process_line(old_line, old_index, block_opened)
|
||||
end
|
||||
|
||||
if @flat_spaces == -1 && tabs - old_tabs > 1
|
||||
raise SyntaxError.new("Illegal Indentation: Indenting more than once per line is illegal.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -655,6 +665,9 @@ module Haml
|
|||
# Counts the tabulation of a line.
|
||||
def count_soft_tabs(line)
|
||||
spaces = line.index(/[^ ]/)
|
||||
if line[spaces] == ?\t
|
||||
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.")
|
||||
end
|
||||
[spaces, spaces/2]
|
||||
end
|
||||
|
||||
|
|
|
@ -121,7 +121,8 @@ class EngineTest < Test::Unit::TestCase
|
|||
def test_syntax_errors
|
||||
errs = [ "!!!\n a", "a\n b", "a\n:foo\nb", "/ a\n b",
|
||||
"% a", "%p a\n b", "a\n%p=\nb", "%p=\n a",
|
||||
"a\n%p~\nb", "a\n~\nb", "%p/\n a"
|
||||
"a\n%p~\nb", "a\n~\nb", "%p/\n a", "%p\n \t%a b",
|
||||
"%a\n b\nc", "%a\n b\nc"
|
||||
]
|
||||
errs.each do |err|
|
||||
begin
|
||||
|
|
Loading…
Reference in a new issue