lib/shell2html.rb in shell2html-0.0.5 vs lib/shell2html.rb in shell2html-0.0.6

- old
+ new

@@ -1,5 +1,7 @@ +require 'cgi' + module Shell2html module_function COLORS = { @@ -65,28 +67,26 @@ t = $2 css = [] key.split(';').each do |i| css << COLORS["#{i.to_i}"] if COLORS["#{i.to_i}"] end + count = 1 if css.count > 0 if inline span_style = css.map do |c| o = [] c[:style].each do |k,v| o << "#{k}:#{v}" end o end.flatten.join(';') - count = 1 "#{'</span>' * count}<span style=\"#{span_style}\">#{t}" else - count = 1 span_class = css.map { |c| c[:css] }.join(' ') "#{'</span>' * count}<span class=\"#{span_class}\">#{t}" end else - count = 1 "#{'</span>' * count}<span>#{t}" end end else e @@ -97,19 +97,25 @@ def css back = [] COLORS.each do |_, c| o = [] css = c[:style].each do |k, v| - o << "#{k}:#{v}" + o << "#{k}: #{v}" end back << ".#{c[:css]} { #{o.join(';')} }" end - back.join("\n") + back.join("\n") + "\n" end - def to_sass(text) - end - - def to_scss(text) + def sass + back = [] + COLORS.each do |_, c| + o = [] + back << ".#{c[:css]}" + c[:style].each do |k, v| + back << " #{k}: #{v}" + end + end + back.join("\n") + "\n" end end