module TrustyCms::Taggable::Util
def self.strip_leading_whitespace(text)
def self.strip_leading_whitespace(text) text = text.dup text.gsub!("\t", ' ') lines = text.split("\n") leading = lines.map do |line| unless line =~ /^\s*$/ line.match(/^(\s*)/)[0].length end end.compact.min lines.inject([]) { |ary, line| ary << line.sub(/^[ ]{#{leading}}/, '') }.join("\n") end
def self.tags_in_array(array)
def self.tags_in_array(array) array.grep(/^tag:/).map { |name| name[4..-1] }.sort end