mirror of
https://gitlab.com/upRootNutrition/website.git
synced 2025-06-16 04:25:11 -05:00
feat: added two articles
This commit is contained in:
parent
a751136971
commit
6cfdf6200e
166 changed files with 3507 additions and 237 deletions
|
@ -26,3 +26,35 @@ wordCount text =
|
|||
text
|
||||
|> String.words
|
||||
|> List.length
|
||||
|
||||
|
||||
toTitleCase : String -> String
|
||||
toTitleCase input =
|
||||
let
|
||||
lowercaseWords =
|
||||
[ "a", "an", "the", "and", "but", "or", "for", "nor", "on", "at", "to", "in", "of", "with", "by" ]
|
||||
|
||||
words =
|
||||
String.words input
|
||||
|
||||
capitalizeFirst word =
|
||||
case String.uncons word of
|
||||
Just ( first, rest ) ->
|
||||
String.toUpper (String.fromChar first) ++ String.toLower rest
|
||||
|
||||
Nothing ->
|
||||
""
|
||||
|
||||
capitalizeWord index word =
|
||||
if index == 0 then
|
||||
capitalizeFirst word
|
||||
|
||||
else if not (List.member (String.toLower word) lowercaseWords) then
|
||||
capitalizeFirst word
|
||||
|
||||
else
|
||||
String.toLower word
|
||||
in
|
||||
words
|
||||
|> List.indexedMap capitalizeWord
|
||||
|> String.join " "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue