class Sass::Engine
def tabulate(string)
def tabulate(string) tab_str = nil comment_tab_str = nil first = true lines = [] string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^.*?$/).each_with_index do |line, index| index += (@options[:line] || 1) if line.strip.empty? lines.last.text << "\n" if lines.last && lines.last.comment? next end line_tab_str = line[/^\s*/] unless line_tab_str.empty? if tab_str.nil? comment_tab_str ||= line_tab_str next if try_comment(line, lines.last, "", comment_tab_str, index) comment_tab_str = nil end tab_str ||= line_tab_str raise SyntaxError.new("Indenting at the beginning of the document is illegal.", :line => index) if first raise SyntaxError.new("Indentation can't use both tabs and spaces.", :line => index) if tab_str.include?(?\s) && tab_str.include?(?\t) end first &&= !tab_str.nil? if tab_str.nil? lines << Line.new(line.strip, 0, index, 0, @options[:filename], []) next end comment_tab_str ||= line_tab_str if try_comment(line, lines.last, tab_str * lines.last.tabs, comment_tab_str, index) next else comment_tab_str = nil end line_tabs = line_tab_str.scan(tab_str).size if tab_str * line_tabs != line_tab_str message = <<END.strip.gsub("\n", ' ') nsistent indentation: #{Haml::Shared.human_indentation line_tab_str, true} used for indentation, the rest of the document was indented using #{Haml::Shared.human_indentation tab_str}. raise SyntaxError.new(message, :line => index) end lines << Line.new(line.strip, line_tabs, index, tab_str.size, @options[:filename], []) end lines end