Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def title_case title small_words= %w[a an and as at but by en for if in of on or the to via] iWords= /\W?[a-z]+[A-Z]/ vs_words= /^vs?\.?$/ title.split.map do |word| case when small_words.include?(word.downcase) word.downcase when word=~ iWords || word=~ vs_words || word.upcase== word word else word.capitalize end end.join(' ').gsub(/^[a-z]+\W/){|first_word|first_word.capitalize} end
This paste will be private.
From the Design Piracy series on my blog: