Use triple-quotes only when necessary

This commit is contained in:
Jeroen Engels 2021-03-11 23:11:42 +01:00
parent ce43a5e627
commit ee98647bcf

View File

@ -68,7 +68,18 @@ formatAlias alias_ =
stringify : String -> String
stringify s =
"\"\"\"" ++ String.replace "\"\"\"" """\\"\\"\\""" s ++ "\"\"\""
s
|> String.replace "\"" "\\\""
|> wrapInQuotes
wrapInQuotes : String -> String
wrapInQuotes s =
if String.contains "\n" s then
"\"\"\"" ++ s ++ "\"\"\""
else
"\"" ++ s ++ "\""
listOfThings : (a -> String) -> List a -> String