Skip to content

Drop separate syntax constructs for markup #371

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

Merged
merged 5 commits into from
Apr 10, 2023

Conversation

eemeli
Copy link
Collaborator

@eemeli eemeli commented Mar 29, 2023

This is a minimally opinionated extension of our {$foo :bar opt=42} placeholder syntax to support markup elements.

The idea here is to drop "markup" as an explicit concept in the syntax and to allow for three different function prefix sigils:

  • : for standalone content
  • + for starting or opening elements
  • - for ending or closing elements

The exact meaning of these standalone/open/close concepts is left undefined, allowing for each of the following styles to be equivalently expressible:

{Click {|a| +html}here{|a| -html} to continue}
{Click {+html.a}here{-html.a} to continue}
{Click {+ph}<a>{-ph}here{+ph}</a>{-ph} to continue}

@eemeli
Copy link
Collaborator Author

eemeli commented Mar 29, 2023

This change simplifies parsing a bit, as declaration, pattern and selectors may now all refer to a single placeholder, rather than each needing to build their own wrappers around expression.

For clarity, I'm also suggesting here to change our language to say that a match statement may contain multiple selectors, rather than being itself a "selector" with multiple "expressions", and that the variants that follow are not a part of the match statement.

Copy link
Collaborator

@stasm stasm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m looking forward to the discussion on Friday about whether open/close are needed in the syntax. Assuming they are, I think this approach is better than our current syntax. That said, I’m still not fond of plus and minus as prefixes. Also, perhaps it would be better to keep the starting : in all cases? As in, :+strong for the opening tag.

@eemeli
Copy link
Collaborator Author

eemeli commented Mar 29, 2023

[...] Also, perhaps it would be better to keep the starting : in all cases? As in, :+strong for the opening tag.

But why? At least to me :+strong and :-strong look much uglier than +strong and -strong, for no real benefit.


expression = ((literal / variable) [s annotation])
/ annotation
expression = "{" [s] (((literal / variable) [s annotation]) / annotation) [s] "}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my action item I am working on ABNF, but we might as well talk about it here. I was going to suggest:

expression = "{" [s] (((literal / variable) [s annotation])
             / annotation) [s] "}"
annotation = (function / reserved) *(s option)
function = ":" name
reserved = (%21-%26 / %2a / %2b / %2d / %2f
           / %3b-%40 / %5e / %7e) name ; reserved sigil characters, specifically these: !"#$%&*+-/^~

I'm reluctant to embrace + and - being "function introducers". I would rather just have a single starter for the "thing we've been calling a function" and having another name for other types of function. If these are different constructs, they should parse to another production name. That can be accommodated by pushing it down a level:

annotation = named *(s option)
named = function / reserved
function = ":" name
reserved = [!@#$%^&*+-<>?] name

This would allow something to become unreserved by adding a named production:

annotation = named *(s option)
named = function / reserved
function = ":" name
fragment = "#" name
reserved = [!@$%^&*+-<>?] name ; deleted # from here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that ultimately anything that may have an argument and/or a bag of options could be represented by some sort of "function". The proposed shape of reserved encodes this as the only possible direction for the extension of the spec, so ultimately anything that would be later un-reserved could effectively be described as a "function introducer".

If we don't want to limit ourselves this way, then really the reserved construct ought to be defined on a higher level, allowing for more freedom (using this PR's syntax as a baseline):

expression = "{" [s] (((literal / variable) [s annotation]) / annotation / reserved) [s] "}"
reserved = reserved-start reserved-body
reserved-start = "!" / "@" / "#" / "$" / "%" / "^" / "&" / "*" / "<" / ">" / "?"
reserved-body = *(reserved-char / reserved-escape / ("{" reserved-body "}") / literal)
reserved-char = %x0-5B         ; omit \
              / %x5D-7A        ; omit { | }
              / %x7E-D7FF      ; omit surrogates
              / %xE000-10FFFF
reserved-escape = backslash ( backslash / "|" / "{" / "}" )

Now, independently of how we might proceed with reserved, I do think that "open" and "close" placeholders are sufficiently common that they definitely should have their own top-level introducers + and -. This leaves us with at least 11 more to use for other concepts, should that prove desirable later on.

@eemeli eemeli marked this pull request as ready for review March 31, 2023 15:57
Copy link
Collaborator

@mihnita mihnita left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@eemeli
Copy link
Collaborator Author

eemeli commented Apr 10, 2023

Merging, as agreed during today's call.

@eemeli eemeli merged commit 7d9f6a7 into unicode-org:main Apr 10, 2023
@eemeli eemeli deleted the min-markup branch April 10, 2023 18:29
eemeli added a commit to messageformat/messageformat that referenced this pull request Jun 6, 2023
eemeli added a commit to messageformat/messageformat that referenced this pull request Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants