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

Give parser ability to automatically collapse repeated property names in a block #6

Open
tabatkins opened this issue May 31, 2016 · 2 comments

Comments

@tabatkins
Copy link
Collaborator

When you have multiple declarations with the same property name in a single block, CSS automatically collapses them for you, retaining only the last one. While we shouldn't opt the generic parser into this by default (other languages might have a good reason to allow multiple declarations with the same name), it would be nice to give the parser an option to do this for you automatically.

@tabatkins
Copy link
Collaborator Author

Oooh, or better idea: treat declaration values with the same property name as monoids. Default to the List monoid so the multiple values just get collected in an array, allow easily opting into CSS's behavior of using the Last monoid, but also allow just providing a "join" callback to the parser that can implement arbitrary monoidal behavior, like merging properties into a conjoined value. (My InfoTree format I invented for Bikeshed, which is vaguely CSSish, has both of these behaviors, depending on the key - some override with last-wins behavior, others combine in a reasonable way.)

@tabatkins
Copy link
Collaborator Author

(Note that this doesn't need to actually mention the word "monoid" anywhere - the options property can just take either an enum or a function.)

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

1 participant