FIX: Title prettify shoundn't downcase all non-ascii titles

This commit is contained in:
Rafael dos Santos Silva 2017-08-08 14:03:24 -03:00
parent e36a20660d
commit 5324c9817f
2 changed files with 5 additions and 1 deletions

View File

@ -31,7 +31,7 @@ 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.to_s 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 == text.mb_chars.upcase)
# Capitalize first letter, but only when entire first word is lowercase
first, rest = text.split(' ', 2)
if first && opts[:capitalize_first_letter] && first == first.mb_chars.downcase

View File

@ -191,6 +191,10 @@ describe TextCleaner do
expect(TextCleaner.clean_title("INVESTIGAÇÃO POLÍTICA NA CÂMARA")).to eq("Investigação política na câmara")
end
it "doesn't downcase text if only one word is upcase in a non-ascii alphabet" do
expect(TextCleaner.clean_title("«Эта неделя в EVE»")).to eq("«Эта неделя в EVE»")
end
it "capitalizes first unicode letter" do
expect(TextCleaner.clean_title("épico encontro")).to eq("Épico encontro")
end