Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions fluent-syntax/src/ftlstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ export class FTLParserStream extends ParserStream {
this.currentPeekIs('.') ||
this.currentPeekIs('#') ||
this.currentPeekIs('[') ||
this.currentPeekIs('*') ||
this.currentPeekIs('{')) {
this.currentPeekIs('*')) {
this.resetPeek();
return false;
}
Expand Down
5 changes: 2 additions & 3 deletions fluent-syntax/src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,10 @@ function getPattern(ps) {
ps.next();
ps.skipLineWS();

firstLine = false;

if (buffer.length !== 0) {
if (!firstLine) {
buffer += ch;
}
firstLine = false;
continue;
} else if (ch === '\\') {
const ch2 = ps.peek();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
key1 =
{ foo }

key2 =
Foo { foo }

key3 =
{ foo } Foo
4 changes: 4 additions & 0 deletions fluent-syntax/test/fixtures_structure/placeable_at_eol.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
key =
A multiline message with a { placeable }
at the end of line. The message should
consist of three lines of text.
42 changes: 42 additions & 0 deletions fluent-syntax/test/fixtures_structure/placeable_at_eol.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"type": "Resource",
"body": [
{
"type": "Message",
"span": {
"type": "Span",
"start": 0,
"end": 130
},
"annotations": [],
"id": {
"type": "Identifier",
"name": "key"
},
"value": {
"type": "Pattern",
"elements": [
{
"type": "TextElement",
"value": "A multiline message with a "
},
{
"type": "MessageReference",
"id": {
"type": "Identifier",
"name": "placeable"
}
},
{
"type": "TextElement",
"value": "\nat the end of line. The message should\nconsist of three lines of text."
}
]
},
"attributes": null,
"tags": null,
"comment": null
}
],
"comment": null
}
13 changes: 0 additions & 13 deletions fluent-syntax/test/serializer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ suite('Serializer', function() {
assert.equal(pretty(input), input);
});

// XXX The Parser ignores the new line after the closing brace
test.skip('multiline with placeable', function() {
const input = ftl`
foo =
Expand All @@ -132,18 +131,6 @@ suite('Serializer', function() {
assert.equal(pretty(input), input);
});

test('multiline with placeable (current)', function() {
const input = ftl`
foo =
Foo { bar }
Baz
`;
const output = ftl`
foo = Foo { bar }Baz
`;
assert.equal(pretty(input), output);
});

test('tag', function() {
const input = ftl`
foo = Foo
Expand Down
2 changes: 1 addition & 1 deletion fluent/src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ class RuntimeParser {
break;
}

if (buffer.length) {
if (buffer.length || content.length) {
buffer += '\n';
}
ch = this._source[this._index];
Expand Down
12 changes: 12 additions & 0 deletions fluent/test/fixtures_structure/placeable_at_eol.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"key": {
"val": [
"A multiline message with a ",
{
"type": "ref",
"name": "placeable"
},
"\nat the end of line. The message should\nconsist of three lines of text."
]
}
}