haml-edge 2.1.24 → 2.1.25

Sign up to get free protection for your applications and to get access to all the features.
data/EDGE_GEM_VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.24
1
+ 2.1.25
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.24
1
+ 2.1.25
data/lib/sass/engine.rb CHANGED
@@ -69,7 +69,11 @@ module Sass
69
69
  #
70
70
  # `children`: [{Array}<{Line}>]
71
71
  # : The lines nested below this one.
72
- Line = Struct.new(:text, :tabs, :index, :offset, :filename, :children)
72
+ class Line < Struct.new(:text, :tabs, :index, :offset, :filename, :children)
73
+ def comment?
74
+ text[0] == COMMENT_CHAR && (text[1] == SASS_COMMENT_CHAR || text[1] == CSS_COMMENT_CHAR)
75
+ end
76
+ end
73
77
 
74
78
  # The character that begins a CSS attribute.
75
79
  ATTRIBUTE_CHAR = ?:
@@ -156,7 +160,8 @@ module Sass
156
160
  def tabulate(string)
157
161
  tab_str = nil
158
162
  first = true
159
- enum_with_index(string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^.*?$/)).map do |line, index|
163
+ lines = []
164
+ string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^.*?$/).each_with_index do |line, index|
160
165
  index += (@options[:line] || 1)
161
166
  next if line.strip.empty?
162
167
 
@@ -170,15 +175,24 @@ module Sass
170
175
  end
171
176
  end
172
177
  first &&= !tab_str.nil?
173
- next Line.new(line.strip, 0, index, 0, @options[:filename], []) if tab_str.nil?
178
+ if tab_str.nil?
179
+ lines << Line.new(line.strip, 0, index, 0, @options[:filename], [])
180
+ next
181
+ end
182
+
183
+ if lines.last && lines.last.comment? && line =~ /^(?:#{tab_str}){#{lines.last.tabs + 1}}(.*)$/
184
+ lines.last.text << "\n" << $1
185
+ next
186
+ end
174
187
 
175
188
  line_tabs = line_tab_str.scan(tab_str).size
176
189
  raise SyntaxError.new(<<END.strip.gsub("\n", ' '), index) if tab_str * line_tabs != line_tab_str
177
190
  Inconsistent indentation: #{Haml::Shared.human_indentation line_tab_str, true} used for indentation,
178
191
  but the rest of the document was indented using #{Haml::Shared.human_indentation tab_str}.
179
192
  END
180
- Line.new(line.strip, line_tabs, index, tab_str.size, @options[:filename], [])
181
- end.compact
193
+ lines << Line.new(line.strip, line_tabs, index, tab_str.size, @options[:filename], [])
194
+ end
195
+ lines
182
196
  end
183
197
 
184
198
  def tree(arr, i = 0)
@@ -51,7 +51,7 @@ module Sass::Tree
51
51
  return if invisible?
52
52
 
53
53
  spaces = ' ' * (tabs - 1)
54
- spaces + "/* " + ([value] + lines.map {|l| l.text}).
54
+ spaces + "/* " + (value.split("\n") + lines.map {|l| l.text}).
55
55
  map{|l| l.sub(%r{ ?\*/ *$},'')}.join(style == :compact ? ' ' : "\n#{spaces} * ") + " */"
56
56
  end
57
57
 
@@ -657,8 +657,7 @@ foo
657
657
  bar: baz
658
658
  SASS
659
659
  assert_equal(<<CSS, actual_css)
660
- /*
661
- * This is a comment that
660
+ /* This is a comment that
662
661
  * continues to the second line. */
663
662
  foo {
664
663
  bar: baz; }
@@ -742,6 +741,24 @@ RESULT
742
741
  SOURCE
743
742
  end
744
743
 
744
+ def test_comment_with_crazy_indentation
745
+ assert_equal(<<CSS, render(<<SASS))
746
+ /* This is a loud comment:
747
+ * Where the indentation is wonky. */
748
+ .comment {
749
+ width: 1px; }
750
+ CSS
751
+ /*
752
+ This is a loud comment:
753
+ Where the indentation is wonky.
754
+ //
755
+ This is a silent comment:
756
+ Where the indentation is wonky.
757
+ .comment
758
+ width: 1px
759
+ SASS
760
+ end
761
+
745
762
  private
746
763
 
747
764
  def render(sass, options = {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haml-edge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.24
4
+ version: 2.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-06-07 00:00:00 -04:00
13
+ date: 2009-06-17 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies: []
16
16