Maintain capitalization in multiword values
Closed this issue · 0 comments
ericcornelissen commented
The existing replacement logic maintains all-caps and capitalization at the start of a word like (for a mapping foo -> bar
):
# All caps
- FOO
+ BAR
# Capitalization
- Foo
+ Bar
However, a value may be more than on word. In such a case it would make sense to keep capitalization of every word in the phrase.
Proposal
The simple and straightforward solution is to keep the capitalization of every word in the phrase, as in (for hello world -> hey planet
):
# Current
- Hello World!
+ Hey planet!
# Wanted
- Hello World!
+ Hey Planet!
This should be extended to symbols other than space, e.g. -
, as in (for so called -> so-called
):
# Current
- So Called
+ So-called
# Wanted
- So Called
+ So-Called
Discussion
Unequal number of words
However, it gets unclear what to do if the "from" and "to" value do not have the same(/a similar) number of words. Consider the following Scenarios
# len(from) > len(to); title case
- Lorem Ipsum Dolor
+ Lorem Dolor
# len(from) > len(to); "random"
- Lorem Ipsum dolor
+ Lorem (D/d)olor
- Lorem ispum Dolor
+ Lorem (D/d)olor
# len(from) < len(to); title case
- Lorem Dolor
+ Lorem (I/i)psum (D/d)olor
- Hello World
+ Hey (B/b)eautiful (P/p)lanet
- Lorem Ipsum Dolor
+ Lorem (I/i)psum (D/d)olor (S/s)it
# len(from) < len(to); random
- Lorem ipsum Dolor
+ Lorem (I/i)psum (D/d)olor (S/s)it
- Lorem Ipsum dolor
+ Lorem (I/i)psum (D/d)olor (S/s)it
From this, it seems clear that at least title case should be maintained 🤔