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

Canonical TOML representation #683

Closed
clarfonthey opened this issue Nov 9, 2019 · 4 comments
Closed

Canonical TOML representation #683

clarfonthey opened this issue Nov 9, 2019 · 4 comments
Labels

Comments

@clarfonthey
Copy link

It would be nice if there were a form of "canonical TOML" that implementors can ascribe to when outputting syntax. For example, how keys should be sorted, exactly when inline tables/arrays should be used versus section headers, when strings should be split into multiple lines, how numbers should be separated, etc.

There could be parameters on the canonical representation, and maybe enforcing a single representation isn't always the best, but at least having some sort of TOML style guide might be useful. Deterministic autoformatting is maybe a lofty goal for this kind of format, even though it's substantially easier for something like JSON.

Corollary: does the order of keys matter in TOML? My best guess is no, but that's another consideration.

@eksortso
Copy link
Contributor

I can't address canonical representation very clearly, though I've tried. There exist formatters, some described on that other issue, which may get you what you're trying to accomplish. But I don't think that the standard will ever define a canonical representation.

Answering your last question: the specification says that key/value pairs within tables are not guaranteed to be in any specific order. So that implies that the order in which keys are defined in the TOML document makes no difference. Although, there are recommendations about keeping dotted keys and subtable definitions together, to avoid confusion.

@lmna
Copy link

lmna commented Nov 11, 2019

Proper formatting (inline VS non-inline, order of keys, etc) depends on specific software that is being configured with given TOML file.

It would be nice if TOML Schema would allow to describe "canonical" formatting.

@pradyunsg
Copy link
Member

pradyunsg commented Dec 13, 2019

I don't have anything to add here. We can explore this at a later date, if there's a strong need. For now though, the language specification does not contain any "canonical" representation and, from my perspective, doesn't need to.

@pradyunsg
Copy link
Member

Thanks for asking @clarfon and for your inputs here @eksortso and @lmna! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants