Skip to content
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

Newline in keys should be escaped #136

Closed
abadger opened this issue Jun 11, 2021 · 1 comment · Fixed by #155
Closed

Newline in keys should be escaped #136

abadger opened this issue Jun 11, 2021 · 1 comment · Fixed by #155

Comments

@abadger
Copy link

abadger commented Jun 11, 2021

Hi I was looking at the tomlkit behaviour with newlines in keys and found a bug:

>>> import tomlkit
>>> tomlkit.__version__
'0.5.11'
>>> print(tomlkit.dumps({'a\nb': 'a\nb'}))
"a
b" = "a\nb"

The toml spec says that the key, equal sign, and value must be on the same line (the value can span multiple lines if it is a multiline string but it must start on the same line as the other parts). ( https://toml.io/en/v1.0.0#keyvalue-pair )

I asked for clarification of what should happen with newlines in key values on the toml lang github and the consensus was that the escaped form of a newline should be used instead of the actual newline: toml-lang/toml#826

Thus the desired behaviour would be for tomlkit.dumps do this:

>>> print(tomlkit.dumps({'a\nb': 'a\nb'}))
"a\nb" = "a\nb"
@srinivasreddy
Copy link
Contributor

Another relevant discussion. toml-lang/toml#835

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants