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

Add support for configuring padding surrounding items in flow collections #419

Closed
cemerick opened this issue Oct 26, 2022 · 2 comments · Fixed by #420
Closed

Add support for configuring padding surrounding items in flow collections #419

cemerick opened this issue Oct 26, 2022 · 2 comments · Fixed by #420

Comments

@cemerick
Copy link
Contributor

I am looking to meet some user expectations/preferences in how flow collections are rendered in YAML that we generate. Specifically, I'd like to avoid the single-space padding that is currently hard-coded around flow collection items:

str = `${start} ${lines.join(' ')} ${end}`

Would you be open to adding a node-level formatting option (much like spaceBefore, etc) to control the size of this padding?

(FWIW, I've looked at using CSTs, but the prospect of building up documents using them vs. the much simpler AST is daunting. Note that these documents are being generated, not parsed from some existing source and modified; if that were the case, then using the CST facilities would be a snap. I can imagine a stringify approach that first distilled an AST to some default CST tree, which one could then modify as desired, but ofc that's not how things are set up. 😄 )

@eemeli
Copy link
Owner

eemeli commented Oct 26, 2022

Sure, the internal padding for single-line flow collections could be made configurable. I think it's more of a ToString Option though? As in, I don't see the need to have this be configurable on a per-node basis, rather than as an overall rule to use for all collections.

@cemerick
Copy link
Contributor Author

Oh sure, that will work, too. Will have a PR for you shortly.

cemerick added a commit to cemerick/yaml that referenced this issue Oct 27, 2022
cemerick added a commit to cemerick/yaml that referenced this issue Oct 27, 2022
@eemeli eemeli linked a pull request Oct 27, 2022 that will close this issue
cemerick added a commit to cemerick/yaml that referenced this issue Oct 27, 2022
cemerick added a commit to cemerick/yaml that referenced this issue Oct 27, 2022
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

Successfully merging a pull request may close this issue.

2 participants