From ee98647bcfc43295666aa5721df4244802adc7fa Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Thu, 11 Mar 2021 23:11:42 +0100 Subject: [PATCH] Use triple-quotes only when necessary --- create-dependency/src/DependencyCreator.elm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/create-dependency/src/DependencyCreator.elm b/create-dependency/src/DependencyCreator.elm index f8253d22..0f038272 100644 --- a/create-dependency/src/DependencyCreator.elm +++ b/create-dependency/src/DependencyCreator.elm @@ -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