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
It would be useful for my project Remarshal and likely for other downstream users of TOML Kit to be able to tell toml.dumps to output multiline arrays. For example, you could call toml.dumps(foo, multiline=True) for only multiline arrays, call toml.dumps(foo, multiline=5) and make arrays with five or more items multiline, or have it based on the line length. Without this feature, you either get output like my TOML example or have to construct the document manually.
The option could also apply to inline tables if a future TOML spec added them.
The text was updated successfully, but these errors were encountered:
I also have a need to write out arrays in multiple lines and discovered the multiline() method on the Array class, which sets a flag to say the Array should be serialized in multiple lines.
What I do is to get a DOM-like representation of my data using item(data) and then I get from that the instances of Array I am interested in, call multiline(True) on them. Finally, I call as_string() on the whole thing to get the serialized TOML that I can write out to a file.
Hope this helps. I know this is not exactly what you asked for but it works for my use case, perhaps it works for you.
@alexvoss Thanks for suggesting this! It works for me, too. I have implemented this approach in my project and credited you for the suggestion: remarshal-project/remarshal@a4560cd.
It would be useful for my project Remarshal and likely for other downstream users of TOML Kit to be able to tell
toml.dumps
to output multiline arrays. For example, you could calltoml.dumps(foo, multiline=True)
for only multiline arrays, calltoml.dumps(foo, multiline=5)
and make arrays with five or more items multiline, or have it based on the line length. Without this feature, you either get output like my TOML example or have to construct the document manually.The option could also apply to inline tables if a future TOML spec added them.
The text was updated successfully, but these errors were encountered: