File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed
packages/mf2-messageformat/src Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 176176 { "type" : " fallback" , "source" : " ?" }
177177 ],
178178 "errors" : [{ "type" : " unsupported-annotation" }]
179+ },
180+ {
181+ "src" : " .foo {42} {{bar}}" ,
182+ "exp" : " bar" ,
183+ "parts" : [{ "type" : " literal" , "value" : " bar" }],
184+ "errors" : [{ "type" : " unsupported-statement" }]
185+ },
186+ {
187+ "src" : " .foo{42}{{bar}}" ,
188+ "cleanSrc" : " .foo {42} {{bar}}" ,
189+ "exp" : " bar" ,
190+ "parts" : [{ "type" : " literal" , "value" : " bar" }],
191+ "errors" : [{ "type" : " unsupported-statement" }]
192+ },
193+ {
194+ "src" : " .foo |}lit{| {42}{{bar}}" ,
195+ "cleanSrc" : " .foo |}lit{| {42} {{bar}}" ,
196+ "exp" : " bar" ,
197+ "parts" : [{ "type" : " literal" , "value" : " bar" }],
198+ "errors" : [{ "type" : " unsupported-statement" }]
179199 }
180200]
Original file line number Diff line number Diff line change @@ -121,7 +121,9 @@ function parseReservedStatement(
121121
122122 const values : CST . Expression [ ] = [ ] ;
123123 while ( ctx . source [ pos ] === '{' ) {
124+ if ( ctx . source . startsWith ( '{{' , pos ) ) break ;
124125 const value = parseExpression ( ctx , pos ) ;
126+ values . push ( value )
125127 end = value . end ;
126128 pos = end + whitespaces ( ctx . source , end ) ;
127129 }
Original file line number Diff line number Diff line change @@ -260,6 +260,7 @@ export function parseReservedBody(
260260 pos = parseQuotedLiteral ( ctx , pos ) . end ;
261261 break ;
262262 case '@' :
263+ case '{' :
263264 case '}' :
264265 break loop;
265266 default : {
@@ -273,7 +274,7 @@ export function parseReservedBody(
273274 }
274275 }
275276 let prev = ctx . source [ pos - 1 ] ;
276- while ( whitespaceChars . includes ( prev ) ) {
277+ while ( pos > start && whitespaceChars . includes ( prev ) ) {
277278 pos -= 1 ;
278279 prev = ctx . source [ pos - 1 ] ;
279280 }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ export function stringifyCST(cst: CST.Message): string {
2727 }
2828 case 'reserved-statement' : {
2929 str += kw ;
30- if ( decl . body ) str += ' ' + decl . body ;
30+ if ( decl . body . value ) str += ' ' + decl . body . value ;
3131 for ( const exp of decl . values ) str += ' ' + stringifyExpression ( exp ) ;
3232 str += '\n' ;
3333 break ;
You can’t perform that action at this time.
0 commit comments