Skip to content

Commit

Permalink
Improved, I think, the Titlecase plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrains committed Nov 27, 2011
1 parent 76af698 commit 343e0f1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/titlecase.rb
Expand Up @@ -11,8 +11,8 @@ def titlecase
# capitalize first and last words # capitalize first and last words
x.first.to_s.smart_capitalize! x.first.to_s.smart_capitalize!
x.last.to_s.smart_capitalize! x.last.to_s.smart_capitalize!
# small words after colons or periods are capitalized # small words are capitalized after colon, period, exclamation mark, question mark
x.join(" ").gsub(/(:|\.)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " } x.join(" ").gsub(/(:|\.|!|\?)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " }
end end


def titlecase! def titlecase!
Expand Down

0 comments on commit 343e0f1

Please sign in to comment.