Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Allow MessageFormat content in function parameters + replace strictNumberSign option with broader strict #8

Merged
merged 7 commits into from
Aug 25, 2018

Conversation

eemeli
Copy link
Member

@eemeli eemeli commented Aug 4, 2018

This is part of a possible solution for messageformat/messageformat#201, and in brief it allows for any formatted content in the optional argStyleText of a custom formatter function. To be clear, this is outside the official spec, not supported by other parsers, and it does theoretically break input that is valid according to the spec:

In argStyleText, every single ASCII apostrophe begins and ends quoted literal text, and unquoted {curly braces} must occur in matched pairs.

This change would not mean that any input that was previously ok with this library would not be ok after the change, as the parameter chars could not previously include an unquoted }.

This change would require a major-version update for messageformat-parser, but probably not for messageformat.

@eemeli eemeli requested a review from SlexAxton August 4, 2018 10:01
eemeli added a commit to messageformat/messageformat that referenced this pull request Aug 4, 2018
This won't work without the proper parser version; use npm link to test
@SlexAxton
Copy link
Member

Initially I’m not a fan of breaking from the spec, but I think maybe I’m ok with it as long as we mark it as non-compliant clearly in the docs or something.

Code looks good.

@eemeli
Copy link
Member Author

eemeli commented Aug 14, 2018

I actually think that the spec is a bit broken on this, as it effectively says that the parameter string should be parsed as if it was a normal formattable string, but that it can't contain any actual formatting. It feels like the spec here just documents the implementation, rather than solving anything in the general case.

@SlexAxton, thoughts on adding a strictFunctionParams or similar flag for this? Not sure if it'd be worth it.

@SlexAxton
Copy link
Member

SlexAxton commented Aug 14, 2018 via email

@eemeli
Copy link
Member Author

eemeli commented Aug 14, 2018

Unfortunately, this is related to messageformat/messageformat#201, where @johanblumenberg found input that is valid according to the spec, but which fails for messageformat. So we're arguably not 100% spec-compliant even now, and while this PR would make us not break on input that looks like it should work, that behaviour would not quite be following the spec.

@SlexAxton
Copy link
Member

SlexAxton commented Aug 15, 2018 via email

@eemeli
Copy link
Member Author

eemeli commented Aug 25, 2018

Updated, now with a single strict option that should follow the spec more closely . This subsumes the strictNumberSign option we had before, and fixes prior non-compliance with functions: argType needs to be one of the preset ones, and the optional parameters are parsed according to spec.

@eemeli eemeli changed the title Allow MessageFormat content in function parameters Allow MessageFormat content in function parameters + replace strictNumberSign option with broader strict Aug 25, 2018
@SlexAxton
Copy link
Member

SlexAxton commented Aug 25, 2018 via email

@eemeli eemeli merged commit 9f8d311 into master Aug 25, 2018
@eemeli eemeli deleted the function-args branch August 25, 2018 18:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants