henry-luo / mark

A simple and unified notation for both object and markup data. (beta)
MIT License
450 stars 15 forks source link

make comma optional #3

Closed pannous closed 6 years ago

pannous commented 6 years ago

{input type:"email", id:"email"} ok {input type:"email" id:"email"} ok

DanCech commented 6 years ago

I was about to ask why the comma is needed at all

henry-luo commented 6 years ago

Thanks for the feedback.

Comma is added merely to make Mark a superset of JSON. And I think JSON has comma added, because it needs to follow JS syntax.

Now since Mark has already broken syntax compatibility with JS, we may consider removing the comma between properties, and it will be more like HTML/XML with less delimiter noise.

I think I can consider making comma optional, as you suggested, just like ';' is optional in JS.

However, if we do that, people may start to ask making ',' optional in array. Should that be optional as well?

pannous commented 6 years ago

@Good point. Thinking about it: Yes, commas should be optional everywhere:
{input type:email id:"email" class=[bold large] style={color:blue width:120} }

if one really needs spaces in identifiers, one can still quote them "strange key":[id1 "long id2" id3]

pannous commented 6 years ago

In one distant utopian future these variants will all have the same meaning

style:{color:blue width:120}
style={color:blue width=120}
style{color:blue width:120}
{style color:blue width:120}

people will cringe at remembering xml, where attributes and children where different.

henry-luo commented 6 years ago

Latest release has made both comma in properties and comma in array optional.

During stringify, the default behavior is still to write the commas, but there's an option now to turn it off.