-
-
Notifications
You must be signed in to change notification settings - Fork 36
Explain why we use |
and not "
and/or '
#465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -596,6 +596,15 @@ A **_<dfn>quoted</dfn>_** literal begins and ends with U+005E VERTICAL BAR `|`. | |||||||||||||||||||||||||||||||||||||||||
The characters `\` and `|` within a _quoted_ literal MUST be | ||||||||||||||||||||||||||||||||||||||||||
escaped as `\\` and `\|`. | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
The `|` is used as a quote delimiter | ||||||||||||||||||||||||||||||||||||||||||
because it is not commonly used as a quote delimiter. | ||||||||||||||||||||||||||||||||||||||||||
Using something more ordinary like `'` or `"` | ||||||||||||||||||||||||||||||||||||||||||
would mean that they would need to be escaped | ||||||||||||||||||||||||||||||||||||||||||
if MessageFormat 2 syntax needed to be included in a resource format | ||||||||||||||||||||||||||||||||||||||||||
that used the same quote delimiter. | ||||||||||||||||||||||||||||||||||||||||||
Supporting both `'` and `"` as quote delimiters would potentially require | ||||||||||||||||||||||||||||||||||||||||||
the delimiters to be manually escaped when copying them between resource formats. | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+601
to
+606
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is why #414 suggests allowing either
and be embedded in JSON as "message": "{'Quoted \"literal\"'}" so only the Hence our explanation ought to say why the above is a worse option than picking a novel quote delimiter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works in JSON, but not in many syntaxes (which are more rigid about quotes). And the quote alternation can depend on the exterior quoting regime not visible to e.g. translation tooling. Changes to the quote characters look like differences to processes such as translation memory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be helpful to just embed something like that example, e.g.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Could you give an example? I'm not sure how a resource syntax could be more rigid about quotes than JSON.
Sure, if you're comparing the exact string representations of messages. However, a reasonable MF2 message comparator would either compare the data model representations of messages, or their understanding of each message's canonical source strings, which would normalise away any whitespace or quotation style differences. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are 2 conveniences that
The combination of these two is particularly interesting: it's when a message both contains quotes in literals and is embedded in code. If we delimited literals with
This is how we get the gnarly |
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
An **_<dfn>unquoted</dfn>_** literal is a _literal_ that does not require the `|` | ||||||||||||||||||||||||||||||||||||||||||
quotes around it to be distinct from the rest of the _message_ syntax. | ||||||||||||||||||||||||||||||||||||||||||
An _unquoted_ MAY be used when the content of the _literal_ | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment on @aphillips's suggestion:
It isn't just that vertical pipes are rare in other syntaxes, but specifically that they are rare as quote delimiters.