Fix a smattering of bugs.
This commit is contained in:
parent
98ee33953a
commit
3b88df6bbe
@ -60,6 +60,7 @@ end
|
|||||||
def possible_filenames_for_stylesheet(ss)
|
def possible_filenames_for_stylesheet(ss)
|
||||||
ext = File.extname(ss)
|
ext = File.extname(ss)
|
||||||
path = File.dirname(ss)
|
path = File.dirname(ss)
|
||||||
|
path = path == "." ? "" : "#{path}/"
|
||||||
base = File.basename(ss)[0..-(ext.size+1)]
|
base = File.basename(ss)[0..-(ext.size+1)]
|
||||||
extensions = if ext.size > 0
|
extensions = if ext.size > 0
|
||||||
[ext]
|
[ext]
|
||||||
@ -70,7 +71,7 @@ def possible_filenames_for_stylesheet(ss)
|
|||||||
filenames = []
|
filenames = []
|
||||||
basenames.each do |basename|
|
basenames.each do |basename|
|
||||||
extensions.each do |extension|
|
extensions.each do |extension|
|
||||||
filenames << "#{path}/#{basename}#{extension}"
|
filenames << "#{path}#{basename}#{extension}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
filenames
|
filenames
|
||||||
@ -132,6 +133,8 @@ def mixin_source_dialog(mixin, &block)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def format_doc(docstring)
|
def format_doc(docstring)
|
||||||
RDiscount.new(docstring).to_html
|
if docstring
|
||||||
|
RDiscount.new(docstring).to_html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ module Sass
|
|||||||
class IfNode < Node
|
class IfNode < Node
|
||||||
def to_sass
|
def to_sass
|
||||||
sass_str = %Q{@if #{@expr.inspect unless @expr.nil?}
|
sass_str = %Q{@if #{@expr.inspect unless @expr.nil?}
|
||||||
- #{tab children_to_sass}
|
- #{children_to_sass}
|
||||||
-}.gsub(/^\s+-/,'')
|
-}.gsub(/^\s+-/,'')
|
||||||
if @else
|
if @else
|
||||||
sass_str << %Q{@else
|
sass_str << %Q{@else
|
||||||
@ -48,12 +48,48 @@ module Sass
|
|||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
class CommentNode < Node
|
||||||
|
def to_sass
|
||||||
|
comment = silent ? "//" : "/*"
|
||||||
|
comment << value
|
||||||
|
lines.each do |line|
|
||||||
|
comment << " " << line
|
||||||
|
end
|
||||||
|
comment
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class RuleNode < Node
|
||||||
|
def to_sass
|
||||||
|
rules.join(",\n")+"\n #{children_to_sass}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class ForNode < Node
|
||||||
|
def to_sass
|
||||||
|
sass_str = "@for !#{@var} from #{@from.to_sass} #{@exclusive ? "to" : "thru"} #{@to.to_sass}"
|
||||||
|
sass_str << "\n #{children_to_sass}"
|
||||||
|
sass_str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
class PropNode < Node
|
||||||
|
def to_sass
|
||||||
|
sass_str = "#{name}"
|
||||||
|
sass_str << (value.is_a?(Script::Node) ? "=" : ":")
|
||||||
|
if value
|
||||||
|
sass_str << " " unless value.nil?
|
||||||
|
sass_str << (value.is_a?(Script::Node) ? value.to_sass : value)
|
||||||
|
end
|
||||||
|
unless (s = children_to_sass).empty?
|
||||||
|
sass_str << "\n #{s}"
|
||||||
|
end
|
||||||
|
sass_str
|
||||||
|
end
|
||||||
|
end
|
||||||
class MixinNode < Node
|
class MixinNode < Node
|
||||||
attr_accessor :name unless method_defined? :name
|
attr_accessor :name unless method_defined? :name
|
||||||
attr_accessor :args unless method_defined? :args
|
attr_accessor :args unless method_defined? :args
|
||||||
def to_sass
|
def to_sass
|
||||||
sass_str = "+#{name}"
|
sass_str = "+#{name}"
|
||||||
if args.any?
|
if args && args.any?
|
||||||
sass_str << "(#{args.map{|a| a.inspect}.join(", ")})"
|
sass_str << "(#{args.map{|a| a.inspect}.join(", ")})"
|
||||||
end
|
end
|
||||||
sass_str
|
sass_str
|
||||||
@ -61,6 +97,9 @@ module Sass
|
|||||||
end
|
end
|
||||||
class VariableNode < Node
|
class VariableNode < Node
|
||||||
attr_accessor :comment unless method_defined? :comment
|
attr_accessor :comment unless method_defined? :comment
|
||||||
|
def to_sass
|
||||||
|
"!#{@name} #{"||" if @guarded}= #{expr.to_sass}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
class MixinDefNode < Node
|
class MixinDefNode < Node
|
||||||
attr_accessor :name unless method_defined? :name
|
attr_accessor :name unless method_defined? :name
|
||||||
@ -83,7 +122,7 @@ module Sass
|
|||||||
|
|
||||||
private
|
private
|
||||||
def arglist_to_sass
|
def arglist_to_sass
|
||||||
if args.any?
|
if args && args.any?
|
||||||
"(#{args.map{|a| arg_to_sass(a)}.join(", ")})"
|
"(#{args.map{|a| arg_to_sass(a)}.join(", ")})"
|
||||||
else
|
else
|
||||||
""
|
""
|
||||||
@ -145,10 +184,10 @@ module Sass
|
|||||||
(self.value * PRECISION).round / PRECISION
|
(self.value * PRECISION).round / PRECISION
|
||||||
end
|
end
|
||||||
value = "#{value}#{numerator_units.first}"
|
value = "#{value}#{numerator_units.first}"
|
||||||
if (nu = numerator_units[1..-1]).any?
|
if (nu = numerator_units[1..-1]) && nu.any?
|
||||||
value << " * " + nu.map{|u| "1#{u}"}.join(" * ")
|
value << " * " + nu.map{|u| "1#{u}"}.join(" * ")
|
||||||
end
|
end
|
||||||
if (du = denominator_units).any?
|
if (du = denominator_units) && du.any?
|
||||||
value << " / " + du.map{|u| "1#{u}"}.join(" / ")
|
value << " / " + du.map{|u| "1#{u}"}.join(" / ")
|
||||||
end
|
end
|
||||||
value
|
value
|
||||||
@ -182,7 +221,7 @@ module Sass
|
|||||||
end
|
end
|
||||||
class String < Literal
|
class String < Literal
|
||||||
def to_sass(format = :text)
|
def to_sass(format = :text)
|
||||||
value.inspect
|
%q{"}+value.gsub(%r{"},%q{\"})+%q{"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class UnaryOperation < Node
|
class UnaryOperation < Node
|
||||||
|
Loading…
Reference in New Issue
Block a user