KenKundert / nestedtext

Human readable and writable data interchange format
https://nestedtext.org
MIT License
376 stars 13 forks source link

Tagless multiline strings #49

Closed MichalMarsalek closed 1 month ago

MichalMarsalek commented 2 months ago

Two years ago a created a nested format with strings, lists and dictionaries for my personal use that was surprisingly similar to NestedText. While it was a bit less elegant than NestedText and still required some escaping, there was one thing that was imo nicer than in NestedText - it supported unannounced multiline strings. In my understanding from quickly reading the docs, I don't think there would be any ambiguity in allowing

key: a dictionary value
     that spans
     multiple lines
another key: another value

and

- a list value
  that spans
  multiple lines
- another value

as shorter alternatives to

key:
  > a dictionary value
  > that spans
  > multiple lines
another key: another value

and

-
  > a dictionary value
  > that spans
  > multiple lines
- another value

I'd love if this was added into the syntax if I'm not missing any clashes.

PS: I added NestedText to https://en.wikipedia.org/wiki/Comparison_of_data-serialization_formats .¨ EDIT: Well it was reverted. Apparently it needs a Wikipedia page first.

MichalMarsalek commented 2 months ago

It could be solved by tooling, but yeah, you are right.

MichalMarsalek commented 1 month ago

The current proposal is not backwards compatible because of the fact that comment lines can be arbitrarily indented. For example,

- value
  # comment

which means ["value"] in current NT, but ["value\n# comment"] under the proposal. To me, this is kind of a dealbreaker. We would need to interpret only otherwise error lines as continuations, which would make this much less elegant and quite confusing. Or we could require comments to be aligned to the parent, but that also breaks backwards compatibility.

KenKundert commented 1 month ago

I agree. This issue is a deal breaker. But even ignoring this issue, I think this proposal is not a good fit for NestedText. It was too limited and added too much potential for confusion.