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

Problem with the preservation of multi-line basic strings #7

Closed
maliknajjar opened this issue Oct 1, 2024 · 6 comments
Closed

Problem with the preservation of multi-line basic strings #7

maliknajjar opened this issue Oct 1, 2024 · 6 comments

Comments

@maliknajjar
Copy link
Owner

maliknajjar commented Oct 1, 2024

Hi @maliknajjar Thanks for the update. There seems to be a new problem with the preservation of multi-line basic strings (acc. to https://toml.io/en/v1.0.0#string):
When I add such a string like in this example:
image
then it is already now displayed in the widget omitting the new lines.
And when I then edit the date (or any other object) using the widgets on the right, then the string is converted to a basic string:
image
While the content is probably still the same, this seems not to be the behavior that the user wants. Would you agree?

Originally posted by @MoritzRitter in #5 (comment)

@maliknajjar
Copy link
Owner Author

Hi @MoritzRitter, thank you for bringing this up.

The issue you're describing is related to the smol-toml TOML parser that the library uses. The parser should check if a string in the JavaScript object contains newline characters (\n). If it does, the string should be formatted as a multi-line TOML string when converting it back to TOML format.

This behavior should preserve the new lines as expected, instead of converting the string into a basic single-line format.

@maliknajjar
Copy link
Owner Author

I opened an issue in the smol-toml library here

@2colours
Copy link

2colours commented Oct 2, 2024

To be honest, this seems simply out of scope for smol-toml since it's not meant as an editor, only a tool that correctly converts between Javascript data representation and TOML data representation which it does correctly. It's a completely different beast to represent semantically equivalent values differently based on some syntax metadata, especially if you are even gonna change the values without saying anything about the metadata.

How does your GUI itself distinguish single line strings and multiline strings? The problem seems to be that it doesn't only not distinguish them but furthermore you somehow dropped the \n that is actually coming from the library.

@maliknajjar
Copy link
Owner Author

@2colours, thanks for your response.

It's a completely different beast to represent semantically equivalent values differently based on some syntax metadata.

got it, so it's not capable of doing that.

How does your GUI itself distinguish between single-line and multi-line strings? The problem seems to be that it not only fails to distinguish them, but also drops the \n that's actually coming from the library.

the GUI doesnt distinguish anything. it just parses and stringifies using the smol-toml library. and it wouldn't really matter. Even if the text editor interpreted the \n correctly, it would result in:

multi_line_string = "Line1
Line2
Line3"

which is invalid TOML syntax.

Essentially, it seems there's no way to get the smol-toml library to produce a multi-line string.

@2colours
Copy link

2colours commented Oct 6, 2024

@maliknajjar I mean it makes exactly the difference of right and wrong whether the GUI produces separate lines as one long line or not.

It is a bug in guifier that it doesn't escape \n as it should and turns "Line1\nLine2\nLine3" into "Line1
Line2
Line3"

@maliknajjar
Copy link
Owner Author

since the smol-toml library doesnt plan on supporting specifying text style in the near future. I will close this for now

@maliknajjar maliknajjar closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
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

No branches or pull requests

2 participants