mirror of
https://github.com/kremalicious/blog.git
synced 2024-12-23 09:45:56 +01:00
fix titlecase
This commit is contained in:
parent
00372c20bb
commit
f9157689bf
@ -9,8 +9,8 @@ class String
|
|||||||
word
|
word
|
||||||
end
|
end
|
||||||
# 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 are capitalized after colon, period, exclamation mark, question mark
|
# 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
|
||||||
|
Loading…
Reference in New Issue
Block a user