mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Handle Capitalize too
Handles capitalize too, using the same lib
This commit is contained in:
parent
71b026bc01
commit
3e6ae45a93
1 changed files with 2 additions and 2 deletions
|
@ -31,9 +31,9 @@ class TextCleaner
|
|||
# Replace ????? with a single ?
|
||||
text.gsub!(/\?+/, '?') if opts[:deduplicate_question_marks]
|
||||
# Replace all-caps text with regular case letters
|
||||
text = text.mb_chars.downcase if opts[:replace_all_upper_case] && (text =~ /[A-Z]+/) && (text == text.upcase)
|
||||
text = text.mb_chars.downcase.to_s if opts[:replace_all_upper_case] && (text =~ /[A-Z]+/) && (text == text.upcase)
|
||||
# Capitalize first letter, but only when entire first word is lowercase
|
||||
text.sub!(/\A([a-z]*)\b/) { |first| first.capitalize } if opts[:capitalize_first_letter]
|
||||
text = text.mb_chars.capitalize.to_s if opts[:capitalize_first_letter] && text.split(' ').first == text.split(' ').first.mb_chars.downcase
|
||||
# Remove unnecessary periods at the end
|
||||
text.sub!(/([^.])\.+(\s*)\z/, '\1\2') if opts[:remove_all_periods_from_the_end]
|
||||
# Remove extraneous space before the end punctuation
|
||||
|
|
Loading…
Reference in a new issue