-
Notifications
You must be signed in to change notification settings - Fork 880
Allow newlines and trailing comma in inline tables #904
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
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -797,23 +797,32 @@ Inline Table | |
| ------------ | ||
|
|
||
| Inline tables provide a more compact syntax for expressing tables. They are | ||
| especially useful for grouped data that can otherwise quickly become verbose. | ||
| Inline tables are fully defined within curly braces: `{` and `}`. Within the | ||
| braces, zero or more comma-separated key/value pairs may appear. Key/value pairs | ||
| take the same form as key/value pairs in standard tables. All value types are | ||
| especially useful for grouped (deeply) nested data that can otherwise quickly | ||
| become verbose. | ||
|
|
||
| Inline tables are defined within curly braces: `{` and `}`. Within the braces, | ||
pradyunsg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| zero or more comma-separated key/value pairs may appear. Key/value pairs take | ||
| the same form as key/value pairs in standard tables. All value types are | ||
| allowed, including inline tables. | ||
|
|
||
| Inline tables are intended to appear on a single line. A terminating comma (also | ||
| called trailing comma) is not permitted after the last key/value pair in an | ||
| inline table. No newlines are allowed between the curly braces unless they are | ||
| valid within a value. Even so, it is strongly discouraged to break an inline | ||
| table onto multiples lines. If you find yourself gripped with this desire, it | ||
| means you should be using standard tables. | ||
| Inline tables can have multiple key/value pairs on the same line, or they can be | ||
| put on different lines. A terminating comma (also called trailing comma) is | ||
| permitted after the last key/value pair. | ||
|
|
||
| ```toml | ||
| name = { first = "Tom", last = "Preston-Werner" } | ||
| point = { x = 1, y = 2 } | ||
| point = {x=1, y=2} | ||
pradyunsg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| animal = { type.name = "pug" } | ||
| contact = { | ||
| personal = { | ||
| name = "Donald Duck", | ||
| email = "[email protected]", | ||
| }, | ||
| work = { | ||
| name = "Coin cleaner", | ||
| email = "[email protected]", | ||
| }, | ||
| } | ||
| ``` | ||
|
|
||
| The inline tables above are identical to the following standard table | ||
|
|
@@ -830,6 +839,14 @@ y = 2 | |
|
|
||
| [animal] | ||
| type.name = "pug" | ||
|
|
||
| [contact.personal] | ||
| name = "Donald Duck" | ||
| email = "[email protected]" | ||
|
|
||
| [contact.work] | ||
| name = "Coin cleaner" | ||
| email = "[email protected]" | ||
| ``` | ||
|
|
||
| Inline tables are fully self-contained and define all keys and sub-tables within | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.