News for hackers. Stuff that matters.
Re:Produce HTML from S-Expressions by lelanthran on Friday September 01, 2023 @01:59AM (#37347331)
> ok, that's reasonable. though you could specify attributes as (:foo bar) so that "(:" always starts an attribute. attributes without value could still be written without surrounding parentheses although always requiring them would make parsing easier.

There's been a lot of pushback on the attributes, so something there has got to change. I'm considering all the changes (including your suggestion too. Thanks, BTW).

The downside #1 with '(:' , from a usage perspective, is that '(' is no longer context-free and is inconsistent. For example, you could not produce a tree with `<:placeholder:>`[1].

Downside #2 is that it's just cumbersome to type (The whole point of this was to reduce the clunkiness of typing out HTML). Four attributes which would be

    :name1=value1 :name2=value2 :name3=value3 :name4=value4
turn into

    (:name1 value1) (:name2 value2) (:name3 value3) (:name4 value4)
I think if I adopt the reverse-smiley, I may as well adopt it in a way that is consistent - reserve all lists which has a ':' as the first symbol. Then, even though it's an exception to the general rule, it's a rule itself so users can easily abide by it and it opens up possibility for new functionality without breaking existing documents.

For example `(:attrs ...)`, and `(:import ...)` and `(:set-var ...)` etc.

[1] I don't know why a user would want this, but it's probable. After all, I use a similar syntax currently in LaTeX files so that sed can perform replacements before pdflatex generates my invoices using the transformed files.

Re:Produce HTML from S-Expressions by em-bee on Friday September 01, 2023 @07:44AM (#37349514)
'(' is no longer context-free and is inconsistent

i would not see it that way. "(" still starts a group, now it would just be either a tag or an attribute.

you could still parse the whole tree into a native data structure based on the parentheses alone (well, except for the significant spaces between tags, but that's another issue), and later look at the first element in each group to decide if it is a tag or an attribute

the same is true when writing. an attribute name starts with a colon ":foo". if you want to add a value to the attribute, you have to use "()" to group it with its name: "(:foo bar)"

another benefit is that you can write: (:class foo bar baz) instead of :class="foo bar baz"