haml-edge 2.1.33 → 2.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/EDGE_GEM_VERSION +1 -1
- data/README.md +27 -27
- data/VERSION +1 -1
- data/lib/haml/exec.rb +4 -2
- data/lib/haml/helpers/action_view_extensions.rb +2 -2
- data/lib/sass/css.rb +17 -15
- data/lib/sass/engine.rb +27 -20
- data/lib/sass/tree/directive_node.rb +7 -7
- data/lib/sass/tree/node.rb +2 -2
- data/lib/sass/tree/{attr_node.rb → prop_node.rb} +15 -15
- data/lib/sass/tree/rule_node.rb +11 -11
- data/test/sass/css2sass_test.rb +27 -27
- data/test/sass/engine_test.rb +25 -25
- metadata +3 -3
data/EDGE_GEM_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.1.
|
|
1
|
+
2.1.34
|
data/README.md
CHANGED
|
@@ -113,15 +113,15 @@ At its most basic,
|
|
|
113
113
|
Sass is just another way of writing CSS.
|
|
114
114
|
Although it's very much like normal CSS,
|
|
115
115
|
the basic syntax offers a few helpful features:
|
|
116
|
-
|
|
116
|
+
indentation indicates the properties in a rule,
|
|
117
117
|
rather than non-DRY brackets;
|
|
118
|
-
and newlines indicate the end of
|
|
118
|
+
and newlines indicate the end of a properties,
|
|
119
119
|
rather than a semicolon.
|
|
120
120
|
For example:
|
|
121
121
|
|
|
122
122
|
#main
|
|
123
|
-
|
|
124
|
-
:
|
|
123
|
+
background-color: #f00
|
|
124
|
+
width: 98%
|
|
125
125
|
|
|
126
126
|
becomes:
|
|
127
127
|
|
|
@@ -163,16 +163,16 @@ So, what was:
|
|
|
163
163
|
becomes:
|
|
164
164
|
|
|
165
165
|
#main
|
|
166
|
-
:
|
|
166
|
+
width: 90%
|
|
167
167
|
p
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
border-style: solid
|
|
169
|
+
border-width: 1px
|
|
170
|
+
border-color: #00f
|
|
171
171
|
a
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
text-decoration: none
|
|
173
|
+
font-weight: bold
|
|
174
174
|
a:hover
|
|
175
|
-
|
|
175
|
+
text-decoration: underline
|
|
176
176
|
|
|
177
177
|
Pretty nice, no? Well, it gets better.
|
|
178
178
|
One of the main complaints against CSS is that it doesn't allow variables.
|
|
@@ -181,19 +181,19 @@ In CSS, you just have to re-type it each time,
|
|
|
181
181
|
which is a nightmare when you decide to change it later.
|
|
182
182
|
Not so for Sass!
|
|
183
183
|
You can use the `!` character to set variables.
|
|
184
|
-
Then, if you put `=` after your
|
|
184
|
+
Then, if you put `=` after your property name,
|
|
185
185
|
you can set it to a variable.
|
|
186
186
|
For example:
|
|
187
187
|
|
|
188
188
|
!note_bg= #55aaff
|
|
189
189
|
|
|
190
190
|
#main
|
|
191
|
-
:
|
|
191
|
+
width: 70%
|
|
192
192
|
.note
|
|
193
|
-
|
|
193
|
+
background-color = !note_bg
|
|
194
194
|
p
|
|
195
|
-
:
|
|
196
|
-
|
|
195
|
+
width: 5em
|
|
196
|
+
background-color = !note_bg
|
|
197
197
|
|
|
198
198
|
becomes:
|
|
199
199
|
|
|
@@ -212,11 +212,11 @@ adding numbers and even colors together:
|
|
|
212
212
|
!main_width= 40em
|
|
213
213
|
|
|
214
214
|
#main
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
background-color = !main_bg
|
|
216
|
+
width = !main_width
|
|
217
217
|
.sidebar
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
background-color = !main_bg + #333333
|
|
219
|
+
width = !main_width - 25em
|
|
220
220
|
|
|
221
221
|
becomes:
|
|
222
222
|
|
|
@@ -228,19 +228,19 @@ becomes:
|
|
|
228
228
|
width: 15em; }
|
|
229
229
|
|
|
230
230
|
Taking the idea of variables a bit further are mixins.
|
|
231
|
-
These let you group whole
|
|
231
|
+
These let you group whole bunches of CSS properties into a single
|
|
232
232
|
directive and then include those anywhere you want:
|
|
233
233
|
|
|
234
234
|
=blue-border
|
|
235
|
-
:
|
|
236
|
-
:
|
|
237
|
-
:
|
|
238
|
-
:
|
|
235
|
+
border:
|
|
236
|
+
color: blue
|
|
237
|
+
width: 2px
|
|
238
|
+
style: dotted
|
|
239
239
|
|
|
240
240
|
.comment
|
|
241
241
|
+blue-border
|
|
242
|
-
:
|
|
243
|
-
:
|
|
242
|
+
padding: 2px
|
|
243
|
+
margin: 10px 0
|
|
244
244
|
|
|
245
245
|
.reply
|
|
246
246
|
+blue-border
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.1.
|
|
1
|
+
2.1.34
|
data/lib/haml/exec.rb
CHANGED
|
@@ -435,10 +435,12 @@ Description: Transforms a CSS file into corresponding Sass code.
|
|
|
435
435
|
Options:
|
|
436
436
|
END
|
|
437
437
|
|
|
438
|
-
opts.on('
|
|
439
|
-
@module_opts[:
|
|
438
|
+
opts.on('--old', 'Output the old-style ":prop val" property syntax') do
|
|
439
|
+
@module_opts[:old] = true
|
|
440
440
|
end
|
|
441
441
|
|
|
442
|
+
opts.on_tail('-a', '--alternate', 'Ignored') {}
|
|
443
|
+
|
|
442
444
|
super
|
|
443
445
|
end
|
|
444
446
|
|
|
@@ -23,12 +23,12 @@ module Haml
|
|
|
23
23
|
# you could refer to this specific action:
|
|
24
24
|
#
|
|
25
25
|
# .entry.show
|
|
26
|
-
#
|
|
26
|
+
# font-weight: bold
|
|
27
27
|
#
|
|
28
28
|
# or to all actions in the entry controller:
|
|
29
29
|
#
|
|
30
30
|
# .entry
|
|
31
|
-
# :
|
|
31
|
+
# color: #00f
|
|
32
32
|
#
|
|
33
33
|
# @return [String] The class name for the current page
|
|
34
34
|
def page_class
|
data/lib/sass/css.rb
CHANGED
|
@@ -24,7 +24,7 @@ module Sass
|
|
|
24
24
|
class RuleNode
|
|
25
25
|
# @see Node#to_sass
|
|
26
26
|
def to_sass(tabs, opts = {})
|
|
27
|
-
str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a?
|
|
27
|
+
str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? PropNode } ? "\n" : ''}"
|
|
28
28
|
|
|
29
29
|
children.each do |child|
|
|
30
30
|
str << "#{child.to_sass(tabs + 1, opts)}"
|
|
@@ -34,10 +34,10 @@ module Sass
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
class
|
|
37
|
+
class PropNode
|
|
38
38
|
# @see Node#to_sass
|
|
39
39
|
def to_sass(tabs, opts = {})
|
|
40
|
-
"#{' ' * tabs}#{opts[:
|
|
40
|
+
"#{' ' * tabs}#{opts[:old] ? ':' : ''}#{name}#{opts[:old] ? '' : ':'} #{value}\n"
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -56,18 +56,20 @@ module Sass
|
|
|
56
56
|
#
|
|
57
57
|
# Example usage:
|
|
58
58
|
#
|
|
59
|
-
# Sass::CSS.new("p { color: blue }").render #=> "p\n :
|
|
59
|
+
# Sass::CSS.new("p { color: blue }").render #=> "p\n color: blue"
|
|
60
60
|
class CSS
|
|
61
61
|
# @param template [String] The CSS code
|
|
62
|
-
# @option options :
|
|
63
|
-
# Whether or not to output
|
|
64
|
-
# (
|
|
62
|
+
# @option options :old [Boolean] (false)
|
|
63
|
+
# Whether or not to output old property syntax
|
|
64
|
+
# (`:color blue` as opposed to `color: blue`).
|
|
65
65
|
def initialize(template, options = {})
|
|
66
66
|
if template.is_a? IO
|
|
67
67
|
template = template.read
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
@options = options
|
|
70
|
+
@options = options.dup
|
|
71
|
+
# Backwards compatibility
|
|
72
|
+
@options[:old] = true if @options[:alternate] == false
|
|
71
73
|
@template = StringScanner.new(template)
|
|
72
74
|
end
|
|
73
75
|
|
|
@@ -133,14 +135,14 @@ module Sass
|
|
|
133
135
|
|
|
134
136
|
assert_match /\{/
|
|
135
137
|
node = Tree::RuleNode.new(rule)
|
|
136
|
-
|
|
138
|
+
properties(node)
|
|
137
139
|
return node
|
|
138
140
|
end
|
|
139
141
|
|
|
140
|
-
# Parses a set of CSS
|
|
142
|
+
# Parses a set of CSS properties within a rule.
|
|
141
143
|
#
|
|
142
|
-
# @param rule [Tree::RuleNode] The parent node of the
|
|
143
|
-
def
|
|
144
|
+
# @param rule [Tree::RuleNode] The parent node of the properties
|
|
145
|
+
def properties(rule)
|
|
144
146
|
while @template.scan(/[^:\}\s]+/)
|
|
145
147
|
name = @template[0]
|
|
146
148
|
whitespace
|
|
@@ -153,7 +155,7 @@ module Sass
|
|
|
153
155
|
end
|
|
154
156
|
|
|
155
157
|
assert_match /(;|(?=\}))/
|
|
156
|
-
rule << Tree::
|
|
158
|
+
rule << Tree::PropNode.new(name, value, nil)
|
|
157
159
|
end
|
|
158
160
|
|
|
159
161
|
assert_match /\}/
|
|
@@ -297,12 +299,12 @@ module Sass
|
|
|
297
299
|
#
|
|
298
300
|
# foo
|
|
299
301
|
# bar
|
|
300
|
-
# :
|
|
302
|
+
# color: red
|
|
301
303
|
#
|
|
302
304
|
# becomes
|
|
303
305
|
#
|
|
304
306
|
# foo bar
|
|
305
|
-
# :
|
|
307
|
+
# color: red
|
|
306
308
|
#
|
|
307
309
|
# and
|
|
308
310
|
#
|
data/lib/sass/engine.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'digest/sha1'
|
|
|
3
3
|
require 'sass/tree/node'
|
|
4
4
|
require 'sass/tree/rule_node'
|
|
5
5
|
require 'sass/tree/comment_node'
|
|
6
|
-
require 'sass/tree/
|
|
6
|
+
require 'sass/tree/prop_node'
|
|
7
7
|
require 'sass/tree/directive_node'
|
|
8
8
|
require 'sass/tree/variable_node'
|
|
9
9
|
require 'sass/tree/mixin_def_node'
|
|
@@ -75,11 +75,11 @@ module Sass
|
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
# The character that begins a CSS
|
|
79
|
-
|
|
78
|
+
# The character that begins a CSS property.
|
|
79
|
+
PROPERTY_CHAR = ?:
|
|
80
80
|
|
|
81
81
|
# The character that designates that
|
|
82
|
-
#
|
|
82
|
+
# a property should be assigned to a SassScript expression.
|
|
83
83
|
SCRIPT_CHAR = ?=
|
|
84
84
|
|
|
85
85
|
# The character that designates the beginning of a comment,
|
|
@@ -106,16 +106,16 @@ module Sass
|
|
|
106
106
|
# Includes named mixin declared using MIXIN_DEFINITION_CHAR
|
|
107
107
|
MIXIN_INCLUDE_CHAR = ?+
|
|
108
108
|
|
|
109
|
-
# The regex that matches
|
|
110
|
-
|
|
111
|
-
ATTRIBUTE = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
|
|
109
|
+
# The regex that matches properties of the form <tt>name: prop</tt>.
|
|
110
|
+
PROPERTY_NEW_MATCHER = /^[^\s:"]+\s*[=:](\s|$)/
|
|
112
111
|
|
|
113
|
-
# The regex that matches
|
|
114
|
-
|
|
112
|
+
# The regex that matches and extracts data from
|
|
113
|
+
# properties of the form <tt>name: prop</tt>.
|
|
114
|
+
PROPERTY_NEW = /^([^\s=:"]+)(\s*=|:)(?:\s+|$)(.*)/
|
|
115
115
|
|
|
116
116
|
# The regex that matches and extracts data from
|
|
117
|
-
#
|
|
118
|
-
|
|
117
|
+
# properties of the form <tt>:name prop</tt>.
|
|
118
|
+
PROPERTY_OLD = /^:([^\s=:"]+)\s*(=?)(?:\s+|$)(.*)/
|
|
119
119
|
|
|
120
120
|
# The default options for Sass::Engine.
|
|
121
121
|
DEFAULT_OPTIONS = {
|
|
@@ -131,6 +131,13 @@ module Sass
|
|
|
131
131
|
def initialize(template, options={})
|
|
132
132
|
@options = DEFAULT_OPTIONS.merge(options)
|
|
133
133
|
@template = template
|
|
134
|
+
|
|
135
|
+
# Backwards compatibility
|
|
136
|
+
@options[:property_syntax] ||= @options[:attribute_syntax]
|
|
137
|
+
case @options[:property_syntax]
|
|
138
|
+
when :alternate; @options[:property_syntax] = :new
|
|
139
|
+
when :normal; @options[:property_syntax] = :old
|
|
140
|
+
end
|
|
134
141
|
end
|
|
135
142
|
|
|
136
143
|
# Render the template to CSS.
|
|
@@ -284,9 +291,9 @@ END
|
|
|
284
291
|
|
|
285
292
|
def parse_line(parent, line, root)
|
|
286
293
|
case line.text[0]
|
|
287
|
-
when
|
|
288
|
-
if line.text[1] !=
|
|
289
|
-
|
|
294
|
+
when PROPERTY_CHAR
|
|
295
|
+
if line.text[1] != PROPERTY_CHAR
|
|
296
|
+
parse_property(line, PROPERTY_OLD)
|
|
290
297
|
else
|
|
291
298
|
# Support CSS3-style pseudo-elements,
|
|
292
299
|
# which begin with ::
|
|
@@ -309,26 +316,26 @@ END
|
|
|
309
316
|
parse_mixin_include(line, root)
|
|
310
317
|
end
|
|
311
318
|
else
|
|
312
|
-
if line.text =~
|
|
313
|
-
|
|
319
|
+
if line.text =~ PROPERTY_NEW_MATCHER
|
|
320
|
+
parse_property(line, PROPERTY_NEW)
|
|
314
321
|
else
|
|
315
322
|
Tree::RuleNode.new(line.text)
|
|
316
323
|
end
|
|
317
324
|
end
|
|
318
325
|
end
|
|
319
326
|
|
|
320
|
-
def
|
|
321
|
-
name, eq, value = line.text.scan(
|
|
327
|
+
def parse_property(line, property_regx)
|
|
328
|
+
name, eq, value = line.text.scan(property_regx)[0]
|
|
322
329
|
|
|
323
330
|
if name.nil? || value.nil?
|
|
324
|
-
raise SyntaxError.new("Invalid
|
|
331
|
+
raise SyntaxError.new("Invalid property: \"#{line.text}\".", @line)
|
|
325
332
|
end
|
|
326
333
|
expr = if (eq.strip[0] == SCRIPT_CHAR)
|
|
327
334
|
parse_script(value, :offset => line.offset + line.text.index(value))
|
|
328
335
|
else
|
|
329
336
|
value
|
|
330
337
|
end
|
|
331
|
-
Tree::
|
|
338
|
+
Tree::PropNode.new(name, expr, property_regx == PROPERTY_OLD ? :old : :new)
|
|
332
339
|
end
|
|
333
340
|
|
|
334
341
|
def parse_variable(line)
|
|
@@ -36,26 +36,26 @@ module Sass::Tree
|
|
|
36
36
|
else
|
|
37
37
|
"#{' ' * (tabs - 1)}#{value} {" + (style == :compact ? ' ' : "\n")
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
was_prop = false
|
|
40
40
|
first = true
|
|
41
41
|
children.each do |child|
|
|
42
42
|
next if child.invisible?
|
|
43
43
|
if style == :compact
|
|
44
|
-
if child.is_a?(
|
|
45
|
-
result << "#{child.to_s(first ||
|
|
44
|
+
if child.is_a?(PropNode)
|
|
45
|
+
result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} "
|
|
46
46
|
else
|
|
47
|
-
if
|
|
47
|
+
if was_prop
|
|
48
48
|
result[-1] = "\n"
|
|
49
49
|
end
|
|
50
50
|
rendered = child.to_s(tabs + 1)
|
|
51
51
|
rendered.lstrip! if first
|
|
52
52
|
result << rendered
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
was_prop = child.is_a?(PropNode)
|
|
55
55
|
first = false
|
|
56
56
|
elsif style == :compressed
|
|
57
|
-
result << (
|
|
58
|
-
|
|
57
|
+
result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1))
|
|
58
|
+
was_prop = child.is_a?(PropNode)
|
|
59
59
|
else
|
|
60
60
|
result << child.to_s(tabs + 1) + "\n"
|
|
61
61
|
end
|
data/lib/sass/tree/node.rb
CHANGED
|
@@ -122,8 +122,8 @@ module Sass
|
|
|
122
122
|
def to_s
|
|
123
123
|
result = String.new
|
|
124
124
|
children.each do |child|
|
|
125
|
-
if child.is_a?
|
|
126
|
-
raise Sass::SyntaxError.new('
|
|
125
|
+
if child.is_a? PropNode
|
|
126
|
+
raise Sass::SyntaxError.new('Properties aren\'t allowed at the root of a document.', child.line)
|
|
127
127
|
else
|
|
128
128
|
next if child.invisible?
|
|
129
129
|
child_str = child.to_s(1)
|
|
@@ -2,7 +2,7 @@ module Sass::Tree
|
|
|
2
2
|
# A static node reprenting a CSS property.
|
|
3
3
|
#
|
|
4
4
|
# @see Sass::Tree
|
|
5
|
-
class
|
|
5
|
+
class PropNode < Node
|
|
6
6
|
# The name of the property.
|
|
7
7
|
#
|
|
8
8
|
# @return [String]
|
|
@@ -16,12 +16,12 @@ module Sass::Tree
|
|
|
16
16
|
|
|
17
17
|
# @param name [String] See \{#name}
|
|
18
18
|
# @param value [String] See \{#value}
|
|
19
|
-
# @param
|
|
19
|
+
# @param prop_syntax [Symbol] `:new` if this property uses `a: b`-style syntax,
|
|
20
20
|
# `:old` if it uses `:a b`-style syntax
|
|
21
|
-
def initialize(name, value,
|
|
21
|
+
def initialize(name, value, prop_syntax)
|
|
22
22
|
@name = name
|
|
23
23
|
@value = value
|
|
24
|
-
@
|
|
24
|
+
@prop_syntax = prop_syntax
|
|
25
25
|
super()
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -39,22 +39,22 @@ module Sass::Tree
|
|
|
39
39
|
# @param tabs [Fixnum] The level of indentation for the CSS
|
|
40
40
|
# @param parent_name [String] The name of the parent property (e.g. `text`) or nil
|
|
41
41
|
# @return [String] The resulting CSS
|
|
42
|
-
# @raise [Sass::SyntaxError] if the
|
|
42
|
+
# @raise [Sass::SyntaxError] if the property uses invalid syntax
|
|
43
43
|
def to_s(tabs, parent_name = nil)
|
|
44
|
-
if @options[:
|
|
45
|
-
raise Sass::SyntaxError.new("Illegal
|
|
46
|
-
elsif @options[:
|
|
47
|
-
raise Sass::SyntaxError.new("Illegal
|
|
44
|
+
if @options[:property_syntax] == :old && @prop_syntax == :new
|
|
45
|
+
raise Sass::SyntaxError.new("Illegal property syntax: can't use new syntax when :property_syntax => :old is set.")
|
|
46
|
+
elsif @options[:property_syntax] == :new && @prop_syntax == :old
|
|
47
|
+
raise Sass::SyntaxError.new("Illegal property syntax: can't use old syntax when :property_syntax => :new is set.")
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
if value[-1] == ?;
|
|
51
|
-
raise Sass::SyntaxError.new("Invalid
|
|
51
|
+
raise Sass::SyntaxError.new("Invalid property: #{declaration.dump} (no \";\" required at end-of-line).", @line)
|
|
52
52
|
end
|
|
53
53
|
real_name = name
|
|
54
54
|
real_name = "#{parent_name}-#{real_name}" if parent_name
|
|
55
55
|
|
|
56
56
|
if value.empty? && children.empty?
|
|
57
|
-
raise Sass::SyntaxError.new("Invalid
|
|
57
|
+
raise Sass::SyntaxError.new("Invalid property: #{declaration.dump} (no value).", @line)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
join_string = case style
|
|
@@ -91,19 +91,19 @@ module Sass::Tree
|
|
|
91
91
|
# Returns an error message if the given child node is invalid,
|
|
92
92
|
# and false otherwise.
|
|
93
93
|
#
|
|
94
|
-
# {
|
|
94
|
+
# {PropNode} only allows other {PropNode}s and {CommentNode}s as children.
|
|
95
95
|
# @param child [Tree::Node] A potential child node
|
|
96
96
|
# @return [String] An error message if the child is invalid, or nil otherwise
|
|
97
97
|
def invalid_child?(child)
|
|
98
|
-
if !child.is_a?(
|
|
99
|
-
"Illegal nesting: Only
|
|
98
|
+
if !child.is_a?(PropNode) && !child.is_a?(CommentNode)
|
|
99
|
+
"Illegal nesting: Only properties may be nested beneath properties."
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
private
|
|
104
104
|
|
|
105
105
|
def declaration
|
|
106
|
-
@
|
|
106
|
+
@prop_syntax == :new ? "#{name}: #{value}" : ":#{name} #{value}"
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
end
|
data/lib/sass/tree/rule_node.rb
CHANGED
|
@@ -79,7 +79,7 @@ module Sass::Tree
|
|
|
79
79
|
def to_s(tabs, super_rules = nil)
|
|
80
80
|
resolved_rules = resolve_parent_refs(super_rules)
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
properties = []
|
|
83
83
|
sub_rules = []
|
|
84
84
|
|
|
85
85
|
rule_separator = style == :compressed ? ',' : ', '
|
|
@@ -96,12 +96,12 @@ module Sass::Tree
|
|
|
96
96
|
if child.is_a? RuleNode
|
|
97
97
|
sub_rules << child
|
|
98
98
|
else
|
|
99
|
-
|
|
99
|
+
properties << child
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
to_return = ''
|
|
104
|
-
if !
|
|
104
|
+
if !properties.empty?
|
|
105
105
|
old_spaces = ' ' * (tabs - 1)
|
|
106
106
|
spaces = ' ' * tabs
|
|
107
107
|
if @options[:line_comments] && style != :compressed
|
|
@@ -124,19 +124,19 @@ module Sass::Tree
|
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
if style == :compact
|
|
127
|
-
|
|
128
|
-
to_return << "#{total_rule} { #{
|
|
127
|
+
properties = properties.map { |a| a.to_s(1) }.select{|a| a && a.length > 0}.join(' ')
|
|
128
|
+
to_return << "#{total_rule} { #{properties} }\n"
|
|
129
129
|
elsif style == :compressed
|
|
130
|
-
|
|
131
|
-
to_return << "#{total_rule}{#{
|
|
130
|
+
properties = properties.map { |a| a.to_s(1) }.select{|a| a && a.length > 0}.join(';')
|
|
131
|
+
to_return << "#{total_rule}{#{properties}}"
|
|
132
132
|
else
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
to_return << "#{total_rule} {\n#{
|
|
133
|
+
properties = properties.map { |a| a.to_s(tabs + 1) }.select{|a| a && a.length > 0}.join("\n")
|
|
134
|
+
end_props = (style == :expanded ? "\n" + old_spaces : ' ')
|
|
135
|
+
to_return << "#{total_rule} {\n#{properties}#{end_props}}\n"
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
|
|
139
|
-
tabs += 1 unless
|
|
139
|
+
tabs += 1 unless properties.empty? || style != :nested
|
|
140
140
|
sub_rules.each do |sub|
|
|
141
141
|
to_return << sub.to_s(tabs, resolved_rules)
|
|
142
142
|
end
|
data/test/sass/css2sass_test.rb
CHANGED
|
@@ -11,27 +11,27 @@ h1 {
|
|
|
11
11
|
CSS
|
|
12
12
|
assert_equal(<<SASS, css2sass(css))
|
|
13
13
|
h1
|
|
14
|
-
:
|
|
14
|
+
color: red
|
|
15
15
|
SASS
|
|
16
|
-
assert_equal(<<SASS, css2sass(css, :
|
|
16
|
+
assert_equal(<<SASS, css2sass(css, :old => true))
|
|
17
17
|
h1
|
|
18
|
-
color
|
|
18
|
+
:color red
|
|
19
19
|
SASS
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def test_nesting
|
|
23
23
|
assert_equal(<<SASS, css2sass(<<CSS))
|
|
24
24
|
li
|
|
25
|
-
:
|
|
25
|
+
display: none
|
|
26
26
|
|
|
27
27
|
a
|
|
28
|
-
|
|
28
|
+
text-decoration: none
|
|
29
29
|
|
|
30
30
|
span
|
|
31
|
-
:
|
|
31
|
+
color: yellow
|
|
32
32
|
|
|
33
33
|
&:hover
|
|
34
|
-
|
|
34
|
+
text-decoration: underline
|
|
35
35
|
SASS
|
|
36
36
|
li {
|
|
37
37
|
display: none;
|
|
@@ -54,15 +54,15 @@ CSS
|
|
|
54
54
|
def test_no_nesting_around_rules
|
|
55
55
|
assert_equal(<<SASS, css2sass(<<CSS))
|
|
56
56
|
div .warning
|
|
57
|
-
:
|
|
57
|
+
color: #d21a19
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
span .debug
|
|
61
|
-
:
|
|
61
|
+
cursor: crosshair
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
div .debug
|
|
65
|
-
:
|
|
65
|
+
cursor: default
|
|
66
66
|
SASS
|
|
67
67
|
div .warning {
|
|
68
68
|
color: #d21a19; }
|
|
@@ -104,24 +104,24 @@ span.turkey {
|
|
|
104
104
|
CSS
|
|
105
105
|
sass = <<SASS
|
|
106
106
|
elephant.rawr
|
|
107
|
-
:
|
|
107
|
+
rampages: excessively
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
span.turkey
|
|
111
|
-
:
|
|
111
|
+
isdinner: true
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
.turducken
|
|
115
|
-
:
|
|
115
|
+
chimera: not_really
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
#overhere
|
|
119
|
-
:
|
|
120
|
-
:
|
|
119
|
+
bored: sorta
|
|
120
|
+
better_than: thread_pools
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
#one_more
|
|
124
|
-
:
|
|
124
|
+
finally: srsly
|
|
125
125
|
SASS
|
|
126
126
|
assert_equal(css2sass(css), sass)
|
|
127
127
|
end
|
|
@@ -130,7 +130,7 @@ SASS
|
|
|
130
130
|
assert_equal(<<SASS, css2sass(<<CSS))
|
|
131
131
|
li
|
|
132
132
|
.one, .two
|
|
133
|
-
:
|
|
133
|
+
color: red
|
|
134
134
|
SASS
|
|
135
135
|
li .one {
|
|
136
136
|
color: red;
|
|
@@ -142,16 +142,16 @@ CSS
|
|
|
142
142
|
|
|
143
143
|
assert_equal(<<SASS, css2sass(<<CSS))
|
|
144
144
|
.one
|
|
145
|
-
:
|
|
145
|
+
color: green
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
.two
|
|
149
|
-
:
|
|
150
|
-
:
|
|
149
|
+
color: green
|
|
150
|
+
color: red
|
|
151
151
|
|
|
152
152
|
|
|
153
153
|
.three
|
|
154
|
-
:
|
|
154
|
+
color: red
|
|
155
155
|
SASS
|
|
156
156
|
.one, .two {
|
|
157
157
|
color: green;
|
|
@@ -166,23 +166,23 @@ CSS
|
|
|
166
166
|
def test_bad_formatting
|
|
167
167
|
assert_equal(<<SASS, css2sass(<<CSS))
|
|
168
168
|
hello
|
|
169
|
-
:
|
|
169
|
+
parent: true
|
|
170
170
|
|
|
171
171
|
there
|
|
172
|
-
:
|
|
172
|
+
parent: false
|
|
173
173
|
|
|
174
174
|
who
|
|
175
|
-
:
|
|
175
|
+
hoo: false
|
|
176
176
|
|
|
177
177
|
why
|
|
178
|
-
:
|
|
178
|
+
y: true
|
|
179
179
|
|
|
180
180
|
when
|
|
181
|
-
:
|
|
181
|
+
wen: nao
|
|
182
182
|
|
|
183
183
|
|
|
184
184
|
down_here
|
|
185
|
-
:
|
|
185
|
+
yeah: true
|
|
186
186
|
SASS
|
|
187
187
|
hello {
|
|
188
188
|
parent: true;
|
data/test/sass/engine_test.rb
CHANGED
|
@@ -15,19 +15,19 @@ class SassEngineTest < Test::Unit::TestCase
|
|
|
15
15
|
"!a = foo(\"bar\"" => 'Expected rparen token, was end of text.',
|
|
16
16
|
"!a = 1 }" => 'Unexpected end_interpolation token.',
|
|
17
17
|
"!a = 1 }foo\"" => 'Unexpected end_interpolation token.',
|
|
18
|
-
":" => 'Invalid
|
|
19
|
-
": a" => 'Invalid
|
|
20
|
-
":= a" => 'Invalid
|
|
21
|
-
"a\n :b" => 'Invalid
|
|
22
|
-
"a\n b:" => 'Invalid
|
|
23
|
-
"a\n :b: c" => 'Invalid
|
|
24
|
-
"a\n :b:c d" => 'Invalid
|
|
25
|
-
"a\n :b=c d" => 'Invalid
|
|
26
|
-
"a\n :b c;" => 'Invalid
|
|
27
|
-
"a\n b: c;" => 'Invalid
|
|
28
|
-
"a\n b : c" => 'Invalid
|
|
29
|
-
"a\n b=c: d" => 'Invalid
|
|
30
|
-
":a" => '
|
|
18
|
+
":" => 'Invalid property: ":".',
|
|
19
|
+
": a" => 'Invalid property: ": a".',
|
|
20
|
+
":= a" => 'Invalid property: ":= a".',
|
|
21
|
+
"a\n :b" => 'Invalid property: ":b " (no value).',
|
|
22
|
+
"a\n b:" => 'Invalid property: "b: " (no value).',
|
|
23
|
+
"a\n :b: c" => 'Invalid property: ":b: c".',
|
|
24
|
+
"a\n :b:c d" => 'Invalid property: ":b:c d".',
|
|
25
|
+
"a\n :b=c d" => 'Invalid property: ":b=c d".',
|
|
26
|
+
"a\n :b c;" => 'Invalid property: ":b c;" (no ";" required at end-of-line).',
|
|
27
|
+
"a\n b: c;" => 'Invalid property: "b: c;" (no ";" required at end-of-line).',
|
|
28
|
+
"a\n b : c" => 'Invalid property: "b : c".',
|
|
29
|
+
"a\n b=c: d" => 'Invalid property: "b=c: d".',
|
|
30
|
+
":a" => 'Properties aren\'t allowed at the root of a document.',
|
|
31
31
|
"!" => 'Invalid variable: "!".',
|
|
32
32
|
"!a" => 'Invalid variable: "!a".',
|
|
33
33
|
"! a" => 'Invalid variable: "! a".',
|
|
@@ -38,7 +38,7 @@ class SassEngineTest < Test::Unit::TestCase
|
|
|
38
38
|
"!a = 2px + #ccc" => "Cannot add a number with units (2px) to a color (#cccccc).",
|
|
39
39
|
"!a = #ccc + 2px" => "Cannot add a number with units (2px) to a color (#cccccc).",
|
|
40
40
|
"& a\n :b c" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 1],
|
|
41
|
-
"a\n :b\n c" => "Illegal nesting: Only
|
|
41
|
+
"a\n :b\n c" => "Illegal nesting: Only properties may be nested beneath properties.",
|
|
42
42
|
"a,\n :b c" => ["Rules can\'t end in commas.", 1],
|
|
43
43
|
"a," => "Rules can\'t end in commas.",
|
|
44
44
|
"a,\n!b = 1" => ["Rules can\'t end in commas.", 1],
|
|
@@ -66,7 +66,7 @@ class SassEngineTest < Test::Unit::TestCase
|
|
|
66
66
|
"=a(,)" => "Mixin arguments can't be empty.",
|
|
67
67
|
"=a(!)" => "Mixin arguments can't be empty.",
|
|
68
68
|
"=a(!foo bar)" => "Invalid variable \"!foo bar\".",
|
|
69
|
-
"=foo\n bar: baz\n+foo" => ["
|
|
69
|
+
"=foo\n bar: baz\n+foo" => ["Properties aren't allowed at the root of a document.", 2],
|
|
70
70
|
"a-\#{!b\n c: d" => ["Expected end_interpolation token, was end of text.", 1],
|
|
71
71
|
"=a(!b = 1, !c)" => "Required arguments must not follow optional arguments \"!c\".",
|
|
72
72
|
"=a(!b = 1)\n :a= !b\ndiv\n +a(1,2)" => "Mixin a takes 1 argument but 2 were passed.",
|
|
@@ -83,7 +83,7 @@ class SassEngineTest < Test::Unit::TestCase
|
|
|
83
83
|
'@debug' => "Invalid debug directive '@debug': expected expression.",
|
|
84
84
|
|
|
85
85
|
# Regression tests
|
|
86
|
-
"a\n b:\n c\n d" => ["Illegal nesting: Only
|
|
86
|
+
"a\n b:\n c\n d" => ["Illegal nesting: Only properties may be nested beneath properties.", 3],
|
|
87
87
|
"& foo\n bar: baz\n blat: bang" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 1],
|
|
88
88
|
"a\n b: c\n& foo\n bar: baz\n blat: bang" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 3],
|
|
89
89
|
}
|
|
@@ -140,7 +140,7 @@ class SassEngineTest < Test::Unit::TestCase
|
|
|
140
140
|
def test_exception_line
|
|
141
141
|
to_render = <<SASS
|
|
142
142
|
rule
|
|
143
|
-
:
|
|
143
|
+
:prop val
|
|
144
144
|
// comment!
|
|
145
145
|
|
|
146
146
|
:broken
|
|
@@ -157,7 +157,7 @@ SASS
|
|
|
157
157
|
def test_exception_location
|
|
158
158
|
to_render = <<SASS
|
|
159
159
|
rule
|
|
160
|
-
:
|
|
160
|
+
:prop val
|
|
161
161
|
// comment!
|
|
162
162
|
|
|
163
163
|
:broken
|
|
@@ -244,21 +244,21 @@ SASS
|
|
|
244
244
|
|
|
245
245
|
def test_colon_only
|
|
246
246
|
begin
|
|
247
|
-
render("a\n b: c", :
|
|
247
|
+
render("a\n b: c", :property_syntax => :old)
|
|
248
248
|
rescue Sass::SyntaxError => e
|
|
249
|
-
assert_equal("Illegal
|
|
249
|
+
assert_equal("Illegal property syntax: can't use new syntax when :property_syntax => :old is set.",
|
|
250
250
|
e.message)
|
|
251
251
|
else
|
|
252
|
-
assert(false, "SyntaxError not raised for :
|
|
252
|
+
assert(false, "SyntaxError not raised for :property_syntax => :old")
|
|
253
253
|
end
|
|
254
254
|
|
|
255
255
|
begin
|
|
256
|
-
render("a\n :b c", :
|
|
256
|
+
render("a\n :b c", :property_syntax => :new)
|
|
257
257
|
rescue Sass::SyntaxError => e
|
|
258
|
-
assert_equal("Illegal
|
|
258
|
+
assert_equal("Illegal property syntax: can't use old syntax when :property_syntax => :new is set.",
|
|
259
259
|
e.message)
|
|
260
260
|
else
|
|
261
|
-
assert(false, "SyntaxError not raised for :
|
|
261
|
+
assert(false, "SyntaxError not raised for :property_syntax => :new")
|
|
262
262
|
end
|
|
263
263
|
end
|
|
264
264
|
|
|
@@ -699,7 +699,7 @@ SASS
|
|
|
699
699
|
|
|
700
700
|
# Regression tests
|
|
701
701
|
|
|
702
|
-
def
|
|
702
|
+
def test_comment_beneath_prop
|
|
703
703
|
assert_equal(<<RESULT, render(<<SOURCE))
|
|
704
704
|
.box {
|
|
705
705
|
border-style: solid; }
|
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.
|
|
4
|
+
version: 2.1.34
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nathan Weizenbaum
|
|
@@ -79,7 +79,7 @@ files:
|
|
|
79
79
|
- lib/sass/script/unary_operation.rb
|
|
80
80
|
- lib/sass/script/variable.rb
|
|
81
81
|
- lib/sass/tree
|
|
82
|
-
- lib/sass/tree/
|
|
82
|
+
- lib/sass/tree/node.rb
|
|
83
83
|
- lib/sass/tree/comment_node.rb
|
|
84
84
|
- lib/sass/tree/debug_node.rb
|
|
85
85
|
- lib/sass/tree/directive_node.rb
|
|
@@ -88,10 +88,10 @@ files:
|
|
|
88
88
|
- lib/sass/tree/if_node.rb
|
|
89
89
|
- lib/sass/tree/mixin_def_node.rb
|
|
90
90
|
- lib/sass/tree/mixin_node.rb
|
|
91
|
-
- lib/sass/tree/node.rb
|
|
92
91
|
- lib/sass/tree/rule_node.rb
|
|
93
92
|
- lib/sass/tree/variable_node.rb
|
|
94
93
|
- lib/sass/tree/while_node.rb
|
|
94
|
+
- lib/sass/tree/prop_node.rb
|
|
95
95
|
- bin/css2sass
|
|
96
96
|
- bin/haml
|
|
97
97
|
- bin/html2haml
|