1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-23 01:30:01 +01:00

fix titlecase

This commit is contained in:
Matthias Kretschmann 2014-07-13 21:17:40 +02:00
parent 00372c20bb
commit f9157689bf

View File

@ -9,8 +9,8 @@ class String
word
end
# capitalize first and last words
#x.first.to_s.smart_capitalize!
#x.last.to_s.smart_capitalize!
x.first.to_s.smart_capitalize!
x.last.to_s.smart_capitalize!
# 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} " }
end