-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Comments from original TOML end up in the wrong spot #295
Comments
It's hard for such level of style-preserving. The parser couldn't know what table the comments should adhere to. |
Would it be an option to add the comment inside the |
I am not in control of the original file - but all comments are on top of the sections so it makes it easier to handle that use case. I wrote a python function to handle that scenario. Basically I find the index/location where I need to insert my new Table, check if the line above is a Comment and if so I do -1 to the index, which preserves the location of the commented line:
|
Hello,
I am using the tomlkit Python library to modify an existing TOML file.
The original file looks like this:
I add two tables to that original array of tables "[[routes]]", with method = 'POST' and path = '/my/post/path'. When I do that, the resulting file becomes:
The comment ends up in the wrong spot. What can I do to make sure it stays on top of my second "[[routes]]" such as:
This is an extract of the code I use to add my 2 tables:
Thank you for your assistance.
The text was updated successfully, but these errors were encountered: