Skip to content

Commit 47c1062

Browse files
eemeliaphillips
andauthored
Accept attributes design & remove spec note (#845)
* Accept attributes design & remove spec note * Disallow duplicate attribute names (closes #756) * Add link to contextual options PR * Add more prose to tag example text Co-authored-by: Addison Phillips <[email protected]> * Mention attribute validity condition in the **_valid_** definition --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent 2d28dc8 commit 47c1062

File tree

6 files changed

+31
-62
lines changed

6 files changed

+31
-62
lines changed

exploration/expression-attributes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Expression Attributes
22

3-
Status: **Proposed**
3+
Status: **Accepted**
44

55
<details>
66
<summary>Metadata</summary>
@@ -15,6 +15,8 @@ Status: **Proposed**
1515
<dd><a href="https://github.com/unicode-org/message-format-wg/pull/772">#772</a></dd>
1616
<dd><a href="https://github.com/unicode-org/message-format-wg/pull/780">#780</a></dd>
1717
<dd><a href="https://github.com/unicode-org/message-format-wg/pull/792">#792</a></dd>
18+
<dd><a href="https://github.com/unicode-org/message-format-wg/pull/845">#845</a></dd>
19+
<dd><a href="https://github.com/unicode-org/message-format-wg/pull/846">#846</a></dd>
1820
</dl>
1921
</details>
2022

spec/data-model/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,6 @@ interface UnsupportedExpression {
203203
annotation: UnsupportedAnnotation;
204204
attributes: Attributes;
205205
}
206-
207-
type Attributes = Map<string, Literal | VariableRef | true>;
208206
```
209207

210208
## Expressions
@@ -283,6 +281,17 @@ interface Markup {
283281
}
284282
```
285283

284+
## Attributes
285+
286+
`Attributes` is a key-value mapping
287+
used to represent the _expression_ and _markup_ _attributes_.
288+
289+
_Attributes_ with no value are represented by `true` here.
290+
291+
```ts
292+
type Attributes = Map<string, Literal | true>;
293+
```
294+
286295
## Extensions
287296

288297
Implementations MAY extend this data model with additional interfaces,

spec/data-model/message.dtd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
<!ELEMENT unsupportedAnnotation (#PCDATA)>
4343

44-
<!ELEMENT attribute (literal | variable)?>
44+
<!ELEMENT attribute (literal)?>
4545
<!ATTLIST attribute name NMTOKEN #REQUIRED>
4646

4747
<!ELEMENT markup (option*, attribute*)>

spec/data-model/message.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"attributes": {
3333
"type": "object",
3434
"additionalProperties": {
35-
"oneOf": [{ "$ref": "#/$defs/literal-or-variable" }, { "const": true }]
35+
"oneOf": [{ "$ref": "#/$defs/literal" }, { "const": true }]
3636
}
3737
},
3838

spec/formatting.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ or even use them in their internal processing,
5858
as long as the final _formatting_ result is made available to users
5959
and the observable behavior of the formatter matches that described here.
6060

61+
_Attributes_ MUST NOT affect the processing or output of a _message_.
62+
6163
## Formatting Context
6264

6365
A message's **_<dfn>formatting context</dfn>_** represents the data and procedures that are required
@@ -762,10 +764,6 @@ MUST be an empty string.
762764
Implementations MAY offer functionality for customizing this,
763765
such as by emitting XML-ish tags for each _markup_.
764766
765-
_Attributes_ are reserved for future standardization.
766-
Other than checking for valid syntax, they SHOULD NOT
767-
affect the processing or output of a _message_.
768-
769767
### Examples
770768
771769
_This section is non-normative._

spec/syntax.md

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Attempting to parse a _message_ that is not _well-formed_ will result in a _Synt
9090
A _message_ is **_<dfn>valid</dfn>_** if it is _well-formed_ and
9191
**also** meets the additional content restrictions
9292
and semantic requirements about its structure defined below for
93-
_declarations_, _matcher_ and _options_.
93+
_declarations_, _matcher_, _options_, and _attributes_.
9494
Attempting to parse a _message_ that is not _valid_ will result in a _Data Model Error_.
9595

9696
## The Message
@@ -154,7 +154,7 @@ message = simple-message / complex-message
154154
155155
A **_<dfn>simple message</dfn>_** contains a single _pattern_,
156156
with restrictions on its first non-whitespace character.
157-
An empty string is a valid _simple message_.
157+
An empty string is a _valid_ _simple message_.
158158

159159
Whitespace at the start or end of a _simple message_ is significant,
160160
and a part of the _text_ of the _message_.
@@ -445,7 +445,7 @@ There MAY be any number of additional _selectors_.
445445
446446
A **_<dfn>variant</dfn>_** is a _quoted pattern_ associated with a list of _keys_ in a _matcher_.
447447
Each _variant_ MUST begin with a sequence of _keys_,
448-
and terminate with a valid _quoted pattern_.
448+
and terminate with a _valid_ _quoted pattern_.
449449
The number of _keys_ in each _variant_ MUST match the number of _selectors_ in the _matcher_.
450450
451451
Each _key_ is separated from each other by whitespace.
@@ -555,7 +555,7 @@ A _function_'s entry in the _function registry_ will define
555555
whether the _function_ is a _selector_ or formatter (or both),
556556
whether an _operand_ is required,
557557
what form the values of an _operand_ can take,
558-
what _options_ and _option_ values are valid,
558+
what _options_ and _option_ values are acceptable,
559559
and what outputs might result.
560560
See [function registry](./registry.md) for more information.
561561

@@ -587,7 +587,7 @@ Multiple _options_ are permitted in an _annotation_.
587587
_Options_ are separated from the preceding _function_ _identifier_
588588
and from each other by whitespace.
589589
Each _option_'s _identifier_ MUST be unique within the _annotation_:
590-
an _annotation_ with duplicate _option_ _identifiers_ is not valid.
590+
an _annotation_ with duplicate _option_ _identifiers_ is not _valid_.
591591
592592
The order of _options_ is not significant.
593593
@@ -723,7 +723,8 @@ markup = "{" [s] "#" identifier *(s option) *(s attribute) [s] ["/"] "}" ; open
723723
> {#button}Submit{/button} or {#img alt=|Cancel| /}.
724724
> ```
725725
726-
> A _message_ with attributes in the closing tag:
726+
> A _message_ containing _markup_ that uses _options_ to pair
727+
> two closing markup _placeholders_ to the one open markup _placeholder_:
727728
>
728729
> ```
729730
> {#ansi attr=|bold,italic|}Bold and italic{/ansi attr=|bold|} italic only {/ansi attr=|italic|} no formatting.}
@@ -737,66 +738,25 @@ on the pairing, ordering, or contents of _markup_ during _formatting_.
737738
738739
## Attributes
739740
740-
**_Attributes_ are reserved for standardization by future versions of this specification._**
741-
Examples in this section are meant to be illustrative and
742-
might not match future requirements or usage.
743-
744-
> [!NOTE]
745-
> The Tech Preview does not provide a built-in mechanism for overriding
746-
> values in the _formatting context_ (most notably the locale)
747-
> Nor does it provide a mechanism for identifying specific expressions
748-
> such as by assigning a name or id.
749-
> The utility of these types of mechanisms has been debated.
750-
> There are at least two proposed mechanisms for implementing support for
751-
> these.
752-
> Specifically, one mechanism would be to reserve specifically-named options,
753-
> possibly using a Unicode namespace (i.e. `locale=xxx` or `u:locale=xxx`).
754-
> Such options would be reserved for use in any and all functions or markup.
755-
> The other mechanism would be to use the reserved "expression attribute" syntax
756-
> for this purpose (i.e. `@locale=xxx` or `@id=foo`)
757-
> Neither mechanism was included in this Tech Preview.
758-
> Feedback on the preferred mechanism for managing these features
759-
> is strongly desired.
760-
>
761-
> In the meantime, function authors and other implementers are cautioned to avoid creating
762-
> function-specific or implementation-specific option values for this purpose.
763-
> One workaround would be to use the implementation's namespace for these
764-
> features to insure later interoperability when such a mechanism is finalized
765-
> during the Tech Preview period.
766-
> Specifically:
767-
> - Avoid specifying an option for setting the locale of an expression as different from
768-
> that of the overall _message_ locale, or use a namespace that later maps to the final
769-
> mechanism.
770-
> - Avoid specifying options for the purpose of linking placeholders
771-
> (such as to pair opening markup to closing markup).
772-
> If such an option is created, the implementer should use an
773-
> implementation-specific namespace.
774-
> Users and implementers are cautioned that such options might be
775-
> replaced with a standard mechanism in a future version.
776-
> - Avoid specifying generic options to communicate with translators and
777-
> translation tooling (i.e. implementation-specific options that apply to all
778-
> functions.
779-
> The above are all desirable features.
780-
> We welcome contributions to and proposals for such features during the
781-
> Technical Preview.
782-
783741
An **_<dfn>attribute</dfn>_** is an _identifier_ with an optional value
784742
that appears in an _expression_ or in _markup_.
743+
During formatting, _attributes_ have no effect,
744+
and they can be treated as code comments.
785745
786746
_Attributes_ are prefixed by a U+0040 COMMERCIAL AT `@` sign,
787747
followed by an _identifier_.
788-
An _attribute_ MAY have a _value_ which is separated from the _identifier_
748+
An _attribute_ MAY have a _literal_ _value_ which is separated from the _identifier_
789749
by an U+003D EQUALS SIGN `=` along with optional whitespace.
790-
The _value_ of an _attribute_ can be either a _literal_ or a _variable_.
791750
792751
Multiple _attributes_ are permitted in an _expression_ or _markup_.
793752
Each _attribute_ is separated by whitespace.
753+
Each _attribute_'s _identifier_ MUST be unique within the _expression_ or _markup_:
754+
an _expression_ or _markup_ with duplicate _attribute_ _identifiers_ is not _valid_.
794755
795756
The order of _attributes_ is not significant.
796757
797-
798758
```abnf
799-
attribute = "@" identifier [[s] "=" [s] (literal / variable)]
759+
attribute = "@" identifier [[s] "=" [s] literal]
800760
```
801761
802762
> Examples of _expressions_ and _markup_ with _attributes_:

0 commit comments

Comments
 (0)