Skip to content

Commit

Permalink
Allow newlines and trailing comma in inline tables
Browse files Browse the repository at this point in the history
  • Loading branch information
arp242 committed May 18, 2022
1 parent cbf3b13 commit 8967065
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## unreleased

* Allow newline after key/values in inline tables.
* Allow trailing comma in inline tables.
* Clarify where and how dotted keys define tables.
* Add new `\e` shorthand for the escape character.

Expand Down
11 changes: 6 additions & 5 deletions toml.abnf
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,14 @@ std-table-close = ws %x5D ; ] Right square bracket

;; Inline Table

inline-table = inline-table-open [ inline-table-keyvals ] inline-table-close
inline-table = inline-table-open [ inline-table-keyvals ] ws-comment-newline inline-table-close

inline-table-open = %x7B ws ; {
inline-table-close = ws %x7D ; }
inline-table-sep = ws %x2C ws ; , Comma
inline-table-open = %x7B ; {
inline-table-close = %x7D ; }
inline-table-sep = %x2C ; , Comma

inline-table-keyvals = keyval [ inline-table-sep inline-table-keyvals ]
inline-table-keyvals = ws-comment-newline keyval ws-comment-newline inline-table-sep inline-table-keyvals
inline-table-keyvals =/ ws-comment-newline keyval ws-comment-newline [ inline-table-sep ]

;; Array Table

Expand Down
20 changes: 10 additions & 10 deletions toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,20 +798,20 @@ 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
Inline tables are 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
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" }
name = {
first = "Tom",
last = "Preston-Werner",
}
point = { x = 1, y = 2 }
animal = { type.name = "pug" }
```
Expand Down

0 comments on commit 8967065

Please sign in to comment.