Skip to content

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

Open

Description

@tabatkins

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.

Activity

  1. tabatkins commented on May 31, 2016

    @tabatkins
    CollaboratorAuthor

    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.)

  2. tabatkins commented on May 31, 2016

    @tabatkins
    CollaboratorAuthor

    (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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions