-
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
Allow single-quoted strings as keys #354
Comments
I ended up running across this today as well, currently the spec allows for basic strings (e.g. double quotes) in key names, but I'd at least find it useful as well to include literal strings as well! In terms of just writing TOML it's quite handy to have a rule of thumb that basic and literal strings are accepted in the same locations. I suppose it also kinda brings up the question of whether multi-line literal strings are accepted in keys but I'd be personally fine saying that's niche enough that I wouldn't want to add it just yet. |
I also think it'd be a good idea to allow literal strings as keys. It feels like disallowing them violates the principle of least surprise. |
cc @mojombo A close reading of the spec and the ABNF do seem to explicitly only permit double quoted strings. Was this intentional? What do you think about expanding it to allow literal strings? |
I agree with allowing literal strings in table keys. I'm guessing the explicit language comes from a time before literal strings existed. I'll get some changed language in shortly. |
Awesome, thanks @mojombo! If you're short on time I also wouldn't mind trying to send a PR, just want to make sure I don't step on any toes! |
@alexcrichton Sure, that would be awesome, thanks! |
This clarifies the definition of "quoted keys" in the section about tables to indicate that keys can either be basic strings (surrounded by double quotes) or literal strings (surrounded by single quotes). Closes toml-lang#354
This clarifies the definition of "quoted keys" in the section about tables to indicate that keys can either be basic strings (surrounded by double quotes) or literal strings (surrounded by single quotes). Closes toml-lang#354
Are there any plans to update the ABNF? If I read it correctly, the ABNF still prohibits single quotes in keys used for tables. |
The following constructs don't work:
But this does:
Since key names look a lot like strings, I think it'd be more consistent if they accepted the full string syntax.
The text was updated successfully, but these errors were encountered: