|
|
|
@ -213,7 +213,19 @@ rec { |
|
|
|
|
outroSpace = if multiline then "\n${indent}" else " "; |
|
|
|
|
in if isInt v then toString v |
|
|
|
|
else if isFloat v then "~${toString v}" |
|
|
|
|
else if isString v then ''"${libStr.escape [''"''] v}"'' |
|
|
|
|
else if isString v then |
|
|
|
|
let |
|
|
|
|
# Separate a string into its lines |
|
|
|
|
newlineSplits = filter (v: ! isList v) (builtins.split "\n" v); |
|
|
|
|
# For a '' string terminated by a \n, which happens when the closing '' is on a new line |
|
|
|
|
multilineResult = "''" + introSpace + concatStringsSep introSpace (lib.init newlineSplits) + outroSpace + "''"; |
|
|
|
|
# For a '' string not terminated by a \n, which happens when the closing '' is not on a new line |
|
|
|
|
multilineResult' = "''" + introSpace + concatStringsSep introSpace newlineSplits + "''"; |
|
|
|
|
# For single lines, replace all newlines with their escaped representation |
|
|
|
|
singlelineResult = "\"" + libStr.escape [ "\"" ] (concatStringsSep "\\n" newlineSplits) + "\""; |
|
|
|
|
in if multiline && length newlineSplits > 1 then |
|
|
|
|
if lib.last newlineSplits == "" then multilineResult else multilineResult' |
|
|
|
|
else singlelineResult |
|
|
|
|
else if true == v then "true" |
|
|
|
|
else if false == v then "false" |
|
|
|
|
else if null == v then "null" |
|
|
|
|