Remix.run Logo
the_mungler 7 hours ago

I'm not the biggest fan of the embed block syntax, for two reasons. 1. Having `%\\\%` escape to `%\\%` is confusing. Assuming you want to embed kson inside kson it would look like this:

```

%kson: level 1

  %kson: level 2

    %kson: level 3

      - "a list"

      - "of values"

    %\\%

  %\%
%%

```

Note that for each level of nesting, the delimiters inside the block have to increase, instead of the ones outside. In a long embedded block you probably copied from elsewhere, you have to check every escaped delimiter to make sure it has the correct number of back slashes and update it. It would have made more sense to have a varying number of % correspond to a matching set to close it. e.g. %%%kson: foo matches %%% and closes it.

2. It's impossible to represent strings where every line has at least some leading indent, because they "always strip their minimum indent".

I think both these issues are solved by using zig's style of raw string literals. An embed block could start with %tag and each following line with % continues the block. No closing delimiter or delimiter escapes needed.

```

%kson: level 1

  %%kson: level 2

  %  %%kson: level 3

  %  %  %  - "a list"

  %  %  %  - "of values"

  %  %  %  - "indented"
```

Granted, this also kind of looks ugly with percent signs. But the upside is you could paste in each sub level, and a text editor could insert the symbols for you before each line, just like they already do when highlighting text and commenting it out.