Parse : Fix titlecase.
This commit is contained in:
parent
31f9ae1f8e
commit
0436631084
|
@ -113,21 +113,15 @@ function parse_uppercase() {
|
|||
# Usage: parse_titlecase <STRING>
|
||||
function parse_titlecase() {
|
||||
local IFS=$'\n'
|
||||
local parts=$(_parse_split ${*})
|
||||
local parts=($(_parse_split ${@}))
|
||||
local minors=("is" "at" "of" "to" "in" "for" "the" "a" "an" "and" "but" "or" "on" "was" "were" "been" "be" "do" "did" "does")
|
||||
local is_first=true
|
||||
|
||||
for part in ${parts[@]}; do
|
||||
if ${is_first}; then
|
||||
echo -n "${part^}"
|
||||
is_first=false
|
||||
continue
|
||||
fi
|
||||
|
||||
if _contains $(echo ${part} | sed -e "s/[${_PARSE_SPLIT_CHARS}]//g") ${minors[@]}; then
|
||||
echo -n "${part}"
|
||||
echo -n "$(parse_sentencecase ${parts[0]})"
|
||||
for part in ${parts[@]:1}; do
|
||||
if _contains $(echo ${part,,} | sed -e "s/[${_PARSE_SPLIT_CHARS}]//g") ${minors[@]}; then
|
||||
echo -n "${part,,}"
|
||||
else
|
||||
echo -n "${part^}"
|
||||
echo -n "$(parse_sentencecase ${part})"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
Reference in a new issue