messageformat / parser

A PEG.js parser for ICU MessageFormat strings
https://messageformat.github.io/
MIT License
7 stars 5 forks source link

\ escaping is not valid MessageFormat #7

Closed eemeli closed 6 years ago

eemeli commented 6 years ago

Following on from messageformat/messageformat.js#171:

We should make \ a non-special character, and just support '{}#' escaping. This also means dropping support for \u0123 Unicode escapes. It should not be the responsibility of the MessageFormat parser to handle those, as it's done by JSON.parse or whichever other tool is turning bytes into a JavaScript string.

Specific use case that should be made easier by this change: atm in order to get the literal string \u0123 from a .json file to the output of the parser requires quadruple-escaping the \, so the file on disc includes something like "\\\\u0123", which is just silly.

As this would be a breaking change, we'd need to increment the parser major version (already released a 2.0 of it earlier...), and I'm working on a codemod for this.

eemeli commented 6 years ago

@SlexAxton I just released messageformat-parser 3.0.0-beta.1 to npm, under the next tag. It drops the \ escapes and includes the codemod.

SlexAxton commented 6 years ago

Sad that that’s the standard, but obviously the right choice. On Sat, Mar 17, 2018 at 7:47 AM Eemeli Aro notifications@github.com wrote:

@SlexAxton https://github.com/slexaxton I just released messageformat-parser 3.0.0-beta.1 to npm, under the next tag. It drops the \ escapes and includes the codemod.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/messageformat/parser/issues/7#issuecomment-373917589, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF5KpSj1bKK3Fo_jMo1Q4iWB5Hu0WYfks5tfQXugaJpZM4SuuZN .