-
Notifications
You must be signed in to change notification settings - Fork 9
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
Preservation of Multi-Line Basic Strings in TOML Parsing #29
Comments
Well, semantically speaking the lib is properly retaining the newline, both strings are byte equivalent. The problem is that you're hitting one of the limitations of the lib: it is not meant for complete preservation of documents, but rather values. It does not care what the original document looked like and will stringify it to whatever the code is outputting. FWIW, this issue applies to:
The question to have formatting options is tracked by #13. Preservation of comments is tracked by #17. I'm inclined to close this as dupe of #13 specifically |
Just to restate here as well: the upstream issue that led to this library maliknajjar/guifier#7 seems to be rather that the GUI input field dropped the newline characters outright. However, that doesn't seem to be caused by the library, and it's not stated in the issue either. |
it wouldn't really matter. Even if the text editor interpreted the
which is invalid TOML syntax. it should be three quotes instead of one
|
so for now. there is no way to produce multi-line strings using the stringify method |
Multi-line strings vs single-line strings is only a stylistic difference. The two examples you've provided in the issue post are byte-equivalent, and is a correct representation of the multiline string. See the TOML spec for strings, specifically multi-line basic strings. With regards to correctness, the lib is working as expected. As I said, using multi-line strings is a stylistic preference which is something tracked under #13. While it is not the prettiest output, newlines are serialized properly. |
Hi,
I've encountered an issue with the preservation of multi-line basic strings while using the smol-toml parser in one of my projects.
When parsing and then converting a multi-line basic string (as defined in the TOML v1.0.0 specification), the new line characters (\n) are not properly retained. Instead, the string is converted into a basic single-line string, even though the original content includes new lines.
For example:
when I parse this into a js object
and then I try to strigify that js object into a toml string again it shows like this
A possible solution is for the parser to check if a string contains a newline character. If it does, the string should be formatted as a multi-line TOML string.
Let me know if further details are needed!
The text was updated successfully, but these errors were encountered: