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

TOML local date not supported #5

Closed
MoritzRitter opened this issue Sep 18, 2024 · 11 comments
Closed

TOML local date not supported #5

MoritzRitter opened this issue Sep 18, 2024 · 11 comments

Comments

@MoritzRitter
Copy link

Acc. to https://toml.io/en/v1.0.0#local-date a local date looks like this:
ld1 = 1979-05-27

However, the TOML Viewer & Editor at https://guifier.com/toml reports an error
Error: SyntaxError: Expected "T" but "\n" found.

Expected behavior: the local date is shown and can be edited.

@maliknajjar
Copy link
Owner

Hi @MoritzRitter
Thank you for helping finding these issues and bugs. really appreciate it

this should be an issue in the toml parser library we are using.
I have to debug it and see exactly whats the cause of this issue.
I will inform asap

@maliknajjar
Copy link
Owner

The issue arises because the toml package on npm is no longer maintained and only supports TOML specification version 0.4.0, which is outdated.
I will try to find an alternative library and replace it.

@maliknajjar
Copy link
Owner

Hi @MoritzRitter,
I've replaced the TOML library with smol-toml, which supports TOML v1.0.0. Additionally, I've implemented a Date field type, allowing the TOML string to be rendered as a date input.

image

You can check it out here:
https://guifier.com/toml/

It now successfully parses the toml date values.

@MoritzRitter
Copy link
Author

Thanks for the update! There seems to be still be a little flaw:

When I open the page, everything is fine:
image

But then, when I edit the date using the widget, the date is written back as string (instead of a local date):
image
Expected: the local date date = 1979-05-28 (without the string quotes "").

@maliknajjar maliknajjar reopened this Sep 26, 2024
@maliknajjar
Copy link
Owner

I will check that asap

@maliknajjar
Copy link
Owner

maliknajjar commented Sep 27, 2024

Currently, when editing the date, it gets parsed into this format:

image

The smol-toml library includes the time by default when handling dates. Based on their documentation, I couldn’t find a way to adjust the parsing behavior to output this specific date format:

image

Does this work for you?

@MoritzRitter
Copy link
Author

Thanks for checking! Let's put it like this: I would need a local date without timezone info etc. And this is not what we have at the moment. But I can work around it. Much better than a parsing error!

@maliknajjar
Copy link
Owner

Got it! Since this is related to the smol-toml library, I’ve opened an issue in their repository. Hopefully, they already have this feature or are willing to implement it.

@maliknajjar
Copy link
Owner

Hi @MoritzRitter I fixed the issue
now it works as expected even if the date is edited from the UI
image

@MoritzRitter
Copy link
Author

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?

@maliknajjar
Copy link
Owner

maliknajjar commented Oct 1, 2024

Hi @MoritzRitter, I created a seperate issue for this #7
you can follow it there

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