haml-edge 2.3.191 → 2.3.192

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.3.191
1
+ 2.3.192
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.191
1
+ 2.3.192
data/lib/sass/engine.rb CHANGED
@@ -6,6 +6,7 @@ require 'sass/tree/rule_node'
6
6
  require 'sass/tree/comment_node'
7
7
  require 'sass/tree/prop_node'
8
8
  require 'sass/tree/directive_node'
9
+ require 'sass/tree/raw_node'
9
10
  require 'sass/tree/variable_node'
10
11
  require 'sass/tree/mixin_def_node'
11
12
  require 'sass/tree/mixin_node'
@@ -485,6 +486,10 @@ WARNING
485
486
  :line => @line + 1) unless line.children.empty?
486
487
  offset = line.offset + line.text.index(value).to_i
487
488
  Tree::DebugNode.new(parse_script(value, :offset => offset))
489
+ elsif directive == "raw"
490
+ raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath raw directives.",
491
+ :line => @line + 1) unless line.children.empty?
492
+ Tree::RawNode.new(value)
488
493
  else
489
494
  Tree::DirectiveNode.new(line.text)
490
495
  end
@@ -276,6 +276,13 @@ module Sass
276
276
  node.has_children = true
277
277
  tok!(/\{/)
278
278
  block_contents(node, context)
279
+
280
+ # Support the hack of having # after all properties.
281
+ if context == :ruleset && tok(/#/)
282
+ node << Sass::Tree::RawNode.new("#")
283
+ ss
284
+ end
285
+
279
286
  tok!(/\}/)
280
287
  node
281
288
  end
@@ -376,8 +383,10 @@ module Sass
376
383
  ['.', expr!(:interp_ident)]
377
384
  end
378
385
 
386
+ # @private
387
+ ID_START = /#(?=#{NMCHAR})/
379
388
  def id_selector
380
- return unless tok(/#(?!\{)/)
389
+ return unless tok(ID_START)
381
390
  @expected = "id name"
382
391
  ['#', expr!(:interp_name)]
383
392
  end
@@ -656,6 +665,15 @@ MESSAGE
656
665
  pos = scanner.pos
657
666
 
658
667
  after = scanner.string[0...pos]
668
+ was = scanner.rest.dup
669
+
670
+ # We support the foo {a: b; #} hack,
671
+ # but we don't want it cluttering our errors.
672
+ if after =~ /\#$/ && expected == '"}"'
673
+ after.slice!(-1)
674
+ was = '#' + was
675
+ end
676
+
659
677
  # Get rid of whitespace between pos and the last token,
660
678
  # but only if there's a newline in there
661
679
  after.gsub!(/\s*\n\s*$/, '')
@@ -663,7 +681,6 @@ MESSAGE
663
681
  after.gsub!(/.*\n/, '')
664
682
  after = "..." + after[-15..-1] if after.size > 18
665
683
 
666
- was = scanner.rest.dup
667
684
  # Get rid of whitespace between pos and the next token,
668
685
  # but only if there's a newline in there
669
686
  was.gsub!(/^\s*\n\s*/, '')
@@ -0,0 +1,33 @@
1
+ module Sass::Tree
2
+ # A static node representing raw CSS.
3
+ # This simply renders a string value.
4
+ #
5
+ # @see Sass::Tree
6
+ class RawNode < Node
7
+ # The text of the hack.
8
+ #
9
+ # @return [String]
10
+ attr_accessor :value
11
+
12
+ # @param value [String] See \{#value}
13
+ def initialize(value)
14
+ @value = value
15
+ super()
16
+ end
17
+
18
+ protected
19
+
20
+ def to_src(tabs, opts, fmt)
21
+ return "#{' ' * tabs}#{value}" if fmt == :scss
22
+ "#{' ' * tabs}@raw #{value}"
23
+ end
24
+
25
+ # Returns the value of the node.
26
+ #
27
+ # @param tabs [Fixnum] The level of indentation for the CSS
28
+ # @return [String] The resulting CSS
29
+ def _to_s(tabs)
30
+ "#{' ' * (tabs - 1)}#{value}"
31
+ end
32
+ end
33
+ end
@@ -777,6 +777,18 @@ SCSS
777
777
  assert_sass_to_scss '$var: 12px $bar baz !default;', '$var ||= 12px $bar "baz"'
778
778
  end
779
779
 
780
+ def test_hash_hack
781
+ assert_renders <<SASS, <<SCSS
782
+ foo
783
+ bar: baz
784
+ @raw #
785
+ SASS
786
+ foo {
787
+ bar: baz;
788
+ # }
789
+ SCSS
790
+ end
791
+
780
792
  # Sass 3 Deprecation conversions
781
793
 
782
794
  def test_simple_quoted_strings_unquoted_with_equals
@@ -56,6 +56,7 @@ MSG
56
56
  "@import foo.sass" => "File to import not found or unreadable: foo.sass.",
57
57
  "a,\n$b: 1" => ["Rules can\'t end in commas.", 1],
58
58
  "$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
59
+ "@raw foo {}\n a: b\n" => "Illegal nesting: Nothing may be nested beneath raw directives.",
59
60
  "@import foo.sass" => <<MSG,
60
61
  File to import not found or unreadable: foo.sass.
61
62
  Load paths:
@@ -589,6 +590,20 @@ END
589
590
  assert_equal("@a{b:c;#d{e:f}g:h}\n", render(to_render, :style => :compressed))
590
591
  end
591
592
 
593
+ def test_raw_directive
594
+ assert_equal(<<CSS, render(<<SASS))
595
+ foo {
596
+ bar {
597
+ baz: bang;
598
+ # }
599
+ CSS
600
+ @raw foo {
601
+ bar
602
+ baz: bang
603
+ @raw #
604
+ SASS
605
+ end
606
+
592
607
  def test_line_annotations
593
608
  assert_equal(<<CSS, render(<<SASS, :line_comments => true, :style => :compact))
594
609
  /* line 2, test_line_annotations_inline.sass */
@@ -352,6 +352,15 @@ foo {
352
352
  SCSS
353
353
  end
354
354
 
355
+ def test_trailing_hash_hack
356
+ assert_parses <<SCSS
357
+ foo {
358
+ foo: bar;
359
+ baz: bang;
360
+ # }
361
+ SCSS
362
+ end
363
+
355
364
  def test_zero_arg_functions
356
365
  assert_parses <<SCSS
357
366
  foo {
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.3.191
4
+ version: 2.3.192
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: 2010-04-06 00:00:00 -04:00
13
+ date: 2010-04-08 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -119,6 +119,7 @@ files:
119
119
  - lib/sass/tree/variable_node.rb
120
120
  - lib/sass/tree/while_node.rb
121
121
  - lib/sass/tree/root_node.rb
122
+ - lib/sass/tree/raw_node.rb
122
123
  - lib/sass/scss/css_parser.rb
123
124
  - lib/sass/scss/parser.rb
124
125
  - lib/sass/scss/rx.rb