Closed RDBModel closed 1 year ago
I was able to fix such behavior by modifying condeList
in Encode.elm:
encodeList : (a -> Encoder) -> EncoderState -> List a -> String
encodeList encode state l =
let
internalString val =
(internalConvertToString
{ state | col = state.col + state.indent, prefix = True }
<< encode
)
val
listElement : a -> String
listElement val =
"-" ++ (if internalString val |> String.startsWith "\n" then
internalString val |> String.trimLeft |> (++) " "
else
internalString val)
prefix : String
prefix =
if state.prefix then
"\n"
else
""
indentAfter : String -> String
indentAfter s =
s ++ String.repeat state.col " "
in
List.map listElement l
|> String.join (indentAfter "\n")
|> String.append (indentAfter prefix)
Seems reasonable. Would you like to submit a PR?
@RDBModel I've just released 2.1.4
which fixes this. Thanks for your help :)
just checked the changes from 2.1.4 on https://rdbmodel.github.io/ and it is working well. Thanks!
Another case that, perhaps, can be improved https://ellie-app.com/k5NYB5sL7zDa1 If there is a list of records, each record will be rendered at a new line: It seems like the following looks better: