ron icon indicating copy to clipboard operation
ron copied to clipboard

Add option for deserialising multiline strings with indentation

Open funnyboy-roks opened this issue 2 months ago • 1 comments

When deserialising a multiline string, an indentation of the lines is added to the string, so if a user doesn't want them to be indented, the lines must be pushed to the left edge.

This causes strings to be fairly hard to read when the field is nested:

(
    foo: (
         bar: "this
is
a
multiline
string"
    )
)

I propose that an option be added to the deserialiser that will support the following:

(
    foo: (
        bar: "this
              is
              a
              multiline
              string"
    )
)

(I think using an option is best so as to not break existing files)

I think the simplest method to do this would be to use the same logic as unindent (or even the crate itself)

funnyboy-roks avatar Oct 03 '25 22:10 funnyboy-roks

There is currently an RFC for Rust to gain de-dented string literals, https://github.com/rust-lang/rfcs/pull/3830. If it is adopted, it would make the most sense for RON to adapt the syntax that this RFC settles on. I'd be happy to accept a PR that adds support for such string literals and for a pretty-print option to use them during serializing, though probably feature-gated until the RFC is accepted.

juntyr avatar Oct 04 '25 19:10 juntyr