-
Notifications
You must be signed in to change notification settings - Fork 859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify whitespace and newline rules. #264
Conversation
|
||
```toml | ||
[table] | ||
key = "value" | ||
``` | ||
|
||
You can indent keys and their values as much as you like. Tabs or spaces. Knock | ||
yourself out. Why, you ask? Because you can have nested tables. Snap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete these two lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indenting is covered by the previous statement that "Whitespace is ignored around key names and values.", so I thought it to be redundant. Also, the ability to indent is a weird way to segue into nested tables, and makes it sound as if indentation might carry some semantic value.
I like the definition of what is and what isn't allowed in keys and table name (parts). A question about the newline handling: this reads to me as if the newline conventions used on the system where a TOML file is created become a permanent part of multiline strings. So assuming the following string comes from a file using Windows newlines:
it would be byte-for-byte equivalent with
Assuming a TOML processor running on Unix reads that file and then creates an updated version, using Unix newlines, this seems to imply it would be forced to serialize the string as
or
Not sure if that's indeed the meaning of the spec. But if it is, I must say that I find it quite unintuitive and possibly annoying. I think it might be better to say approximately the following:
That's approximately what Python's "universal newline mode" does. |
cc @BurntSushi - I'd love your opinion on this. |
I should also mention that depending on the outcome of #220 the key/table name rules may change. This PR is primarily to get the newline issue nailed down. |
@@ -62,6 +62,7 @@ Spec | |||
|
|||
* TOML is case sensitive. | |||
* Whitespace means tab (0x09) or space (0x20). | |||
* Newline means CR (0x0A) or LF (0x0D). | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if Newline
was defined as either \r\n
or \n
. This leaves out a lone \r
as qualifying as a new line, but I think this OK, unless it's still commonly used somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
\r
was once used on Mac, but Mac OS X changed that AFAIK.
Ok, I've made a few changes to define newline as LF or CRLF and tightened up the copy to reflect that change. cc @BurntSushi @ChristianSi - I'd love your thoughts on the new text. |
@ChristianSi Ok, just pushed a small edit for that. |
LGTM. :-) |
Ok, thanks for your feedback on this, everyone. Merging! |
Clarify whitespace and newline rules.
This PR greatly clarifies the use of whitespace and newlines in TOML. A few notes and ramifications: