You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the application where I also stumble on the problem to serialize empty TOML arrays, I also have some multi line strings. As far as I understand the TOML standard, a string in a single quotation mark cannot contain newlines.
So locally I've applied a patch like:
basti at void in ~/src/nim/parsetoml ツ git diff
diff --git a/src/parsetoml.nim b/src/parsetoml.nim
index 06d41f1..f8a5a56 100644
--- a/src/parsetoml.nim+++ b/src/parsetoml.nim@@ -1510,8 +1510,12 @@ proc toTomlString*(value: TomlValueRef): string =
of TomlValueKind.Int: $value.intVal
of TomlValueKind.Float: $value.floatVal
of TomlValueKind.Bool: $value.boolVal
- of TomlValueKind.Datetime: $value.dateTimeVal- of TomlValueKind.String: "\"" & value.stringVal & "\""+ of TomlValueKind.Datetime: $value.datetimeVal+ of TomlValueKind.String:+ if '\n' in value.stringVal:+ "'''" & value.stringVal & "\n'''"+ else:+ "\"" & value.stringVal & "\""
of TomlValueKind.Array:
if value.arrayVal.len == 0:
"[]"
On the one hand this feels a bit like a hack. But I mainly didn't open a PR for this, because I'm not sure how to decide whether to use a regular multi line string with quotation marks or one with single ticks. In my use case I want the string to be literal anyway.
Any ideas for how to deal with this?
The text was updated successfully, but these errors were encountered:
The easiest would probably be to always use the most lenient string representation. But otherwise this seems like a solution that would work. Only problem is that you seem to add an extra newline to the string?
In the application where I also stumble on the problem to serialize empty TOML arrays, I also have some multi line strings. As far as I understand the TOML standard, a string in a single quotation mark cannot contain newlines.
So locally I've applied a patch like:
On the one hand this feels a bit like a hack. But I mainly didn't open a PR for this, because I'm not sure how to decide whether to use a regular multi line string with quotation marks or one with single ticks. In my use case I want the string to be literal anyway.
Any ideas for how to deal with this?
The text was updated successfully, but these errors were encountered: