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

Write layout - "As flat as possible option" #35

Open
frankhommers opened this issue Jan 13, 2022 · 2 comments
Open

Write layout - "As flat as possible option" #35

frankhommers opened this issue Jan 13, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@frankhommers
Copy link

I have read this:

The writer does not currently preserve the layout of the original document! This is to save size and keep things simple for now.

But I have a file with a lot of nested stuff.
For instance:

[date.1]
RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))(\\-|\\/| \\- )(?<Month>(0[1-9]|[1-9]|1[0-2]))(\\-|\\/| \\- )(?<Year>((20|19)\\d\\d))"
Priority = 1

[date.2]
RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))(\\.|\\s|)+(?<MonthText>(jan|feb|maa|apr|mei|jun|jul|aug|sep|okt|nov|dec)).{0,6}(\\.|\\s|)+(?<Year>((20|19)\\d\\d))"
Priority = 2

[date.3]
RegEx = "(?<MonthText>(jan|feb|maa|apr|mei|jun|jul|aug|sep|okt|nov|dec)).{0,6}(\\.|\\s)+(?<Year>((20|19)\\d\\d))"
Priority = 3

[date.4]
RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))\\.(?<Month>(0[1-9]|[1-9]|1[0-2]))\\.(?<Year>((20|19)\\d\\d))"
Priority = 4

[date.5]
RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))(\\-|\\/)(?<Month>(0[1-9]|[1-9]|1[0-2]))(\\-|\\/)(?<YearMod100>(0|1|2)\\d)"
Priority = 5

[date.6]
RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))\\s?(\\-|\\/| \\- )\\s?(?<Month>(0[1-9]|[1-9]|1[0-2]))\\s?(\\-|\\/| \\- )\\s?(?<Year>((20|19)\\d\\d))"
Priority = 6

[date.7]
RegEx = "(?<Year>((20|19)\\d\\d))(\\-|\\/| \\- |\\.)?(?<Month>(0[1-9]|[1-9]|1[0-2]))(\\-|\\/| \\- |\\.)?(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))"
Priority = 1

That will get pretty hard to use after saving:

date = { 1 = { RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))(\\-|\\/| \\- )(?<Month>(0[1-9]|[1-9]|1[0-2]))(\\-|\\/| \\- )(?<Year>((20|19)\\d\\d))", Priority = 1 }, 2 = { RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))(\\.|\\s|)+(?<MonthText>(jan|feb|maa|apr|mei|jun|jul|aug|sep|okt|nov|dec)).{0,6}(\\.|\\s|)+(?<Year>((20|19)\\d\\d))", Priority = 2 }, 3 = { RegEx = "(?<MonthText>(jan|feb|maa|apr|mei|jun|jul|aug|sep|okt|nov|dec)).{0,6}(\\.|\\s)+(?<Year>((20|19)\\d\\d))", Priority = 3 }, 4 = { RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))\\.(?<Month>(0[1-9]|[1-9]|1[0-2]))\\.(?<Year>((20|19)\\d\\d))", Priority = 4 }, 5 = { RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))(\\-|\\/)(?<Month>(0[1-9]|[1-9]|1[0-2]))(\\-|\\/)(?<YearMod100>(0|1|2)\\d)", Priority = 5 }, 6 = { RegEx = "(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))\\s?(\\-|\\/| \\- )\\s?(?<Month>(0[1-9]|[1-9]|1[0-2]))\\s?(\\-|\\/| \\- )\\s?(?<Year>((20|19)\\d\\d))", Priority = 6 }, 7 = { RegEx = "(?<Year>((20|19)\\d\\d))(\\-|\\/| \\- |\\.)?(?<Month>(0[1-9]|[1-9]|1[0-2]))(\\-|\\/| \\- |\\.)?(?<Day>(0[1-9]|[1-9]|[1-2][0-9]|[3][0-1]))", Priority = 1 } }

Would it be possible to introduce a flag during writing which will write the file as flat (or elaborate) as possible.
Meaning generating a [part] wherever possible ?

@dezhidki
Copy link
Owner

dezhidki commented Jan 13, 2022

Hi!

Thanks for the example. This example looks more like a bug in the parser where it tries to interpret the data table in data.1 as an inline table because it was not explicitly defined before. If my guess is correct, adding [data] at the start of the file will suddenly fix parsing and writing. I'll mark this as a bug and have a proper look.

@dezhidki dezhidki added the bug Something isn't working label Jan 13, 2022
@frankhommers
Copy link
Author

Now you got me hoping for two things ;-) The bug being fixed and the flattening option ;-)

@frankhommers frankhommers reopened this Jan 14, 2022
dezhidki added a commit that referenced this issue Jan 16, 2022
dezhidki added a commit that referenced this issue Jan 16, 2022
Doesn't yet allow to flatten TOML on output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants