Skip to content

Commit 22da361

Browse files
zbranieckistasm
authored andcommitted
Support empty comment lines in runtime parser (#149)
1 parent f676215 commit 22da361

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# This is
3+
#
4+
# An example of a multiline comment
5+
6+
key = Value
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"type": "Resource",
3+
"body": [
4+
{
5+
"type": "Comment",
6+
"annotations": [],
7+
"content": "This is\n\nAn example of a multiline comment",
8+
"span": {
9+
"type": "Span",
10+
"start": 1,
11+
"end": 48
12+
}
13+
},
14+
{
15+
"type": "Message",
16+
"annotations": [],
17+
"id": {
18+
"type": "Identifier",
19+
"name": "key",
20+
"span": {
21+
"type": "Span",
22+
"start": 50,
23+
"end": 53
24+
}
25+
},
26+
"value": {
27+
"type": "Pattern",
28+
"elements": [
29+
{
30+
"type": "TextElement",
31+
"value": "Value",
32+
"span": {
33+
"type": "Span",
34+
"start": 56,
35+
"end": 61
36+
}
37+
}
38+
],
39+
"span": {
40+
"type": "Span",
41+
"start": 56,
42+
"end": 61
43+
}
44+
},
45+
"attributes": [],
46+
"comment": null,
47+
"span": {
48+
"type": "Span",
49+
"start": 50,
50+
"end": 61
51+
}
52+
}
53+
],
54+
"span": {
55+
"type": "Span",
56+
"start": 0,
57+
"end": 62
58+
}
59+
}

fluent/src/parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class RuntimeParser {
7575

7676
// We don't care about comments or sections at runtime
7777
if (ch === '/' ||
78-
(ch === '#' && [' ', '#'].includes(this._source[this._index + 1]))) {
78+
(ch === '#' &&
79+
[' ', '#', '\n'].includes(this._source[this._index + 1]))) {
7980
this.skipComment();
8081
return;
8182
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"key": "Value"
3+
}

0 commit comments

Comments
 (0)