Skip to content

Commit 619cfe7

Browse files
authored
Open/close design: A familiar HTML-like syntax as an alternative (#516)
* Add an alternative: new declarations and a familiar syntax * Remove open/close declarations; I'll create a new design for them * Add a link to 518 about unquoted literals as operands
1 parent f352b66 commit 619cfe7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

exploration/open-close-expressions.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Status: **Proposed**
88
<dt>Contributors</dt>
99
<dd>@eemeli</dd>
1010
<dd>@aphillips</dd>
11+
<dd>@stasm</dd>
1112
<dt>First proposed</dt>
1213
<dd>2023-09-05</dd>
1314
<dt>Pull Request</dt>
@@ -220,3 +221,51 @@ Rendered as React this could become:
220221
_What other solutions are available?_
221222
_How do they compare against the requirements?_
222223
_What other properties they have?_
224+
225+
### HTML-like syntax
226+
227+
The goal of this solution is to avoid adding new sigils to the syntax.
228+
Instead, it leverages the familiarity of the `foo`...`/foo` idiom,
229+
inspired by HTML and BBCode.
230+
231+
This solution consists of adding new placeholder syntax:
232+
`{foo}`, `{/foo}`, and `{foo/}`.
233+
234+
```
235+
This is {html:strong}bold{/html:strong} and this is {html:img alt=|an image|/}.
236+
```
237+
238+
Markup names are *effectively namespaced* due to their not using any sigils;
239+
they are distinct from `$variables`, `:functions`, and `|literals|`.
240+
241+
> [!NOTE]
242+
> This requires dropping unquoted literals as operands,
243+
> so that `{foo}` is not parsed as `{|foo|}`.
244+
> See [#518](https://github.com/unicode-org/message-format-wg/issues/518).
245+
246+
The exact meaning of the new placeholer types is as follows:
247+
248+
* `{foo}` is a span-open.
249+
* `{/foo}` is a span-close.
250+
* `{foo/}` is a standalone element.
251+
252+
#### Pros
253+
254+
* Doesn't add new sigils except for `/`,
255+
which is universally known thanks to the wide-spread use of HTML.
256+
257+
* Using syntax inspired by HTML makes it familiar to most translators.
258+
Prior art for a similar inspiration can be found in the [BBCode](https://en.wikipedia.org/wiki/BBCode) syntax,
259+
which uses `[foo]` and `[/foo]` as tags.
260+
Despite being a niche language, BBCode can be argued to be many people's first introduction to markup-like syntax.
261+
262+
* Avoids the issues of using JSX-style syntax, `<foo>`...`</foo>`,
263+
which looks *exactly* like HTML, but has different semantics and behavior.
264+
265+
#### Cons
266+
267+
* May still be confusing because it looks almost like HTML, but doesn't use the familiar angle brackets.
268+
269+
* Requires changes to the existing MF2 syntax: dropping unquoted literals as expression operands.
270+
271+
* Regular placeholders, e.g. `{$var}`, use the same `{...}` syntax, and may be confused for *open* elements.

0 commit comments

Comments
 (0)