Skip to content

Commit a6ccb2d

Browse files
authored
Treat tab as text, not whitespace (#606)
1 parent e99614e commit a6ccb2d

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

fluent-bundle/test/fixtures_reference/tab.json

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
"This line is indented by 4 spaces,"
1212
],
1313
"attributes": {}
14+
},
15+
{
16+
"id": "key05",
17+
"value": "\t",
18+
"attributes": {}
19+
},
20+
{
21+
"id": "key06",
22+
"value": null,
23+
"attributes": {
24+
"attr": "\t\t"
25+
}
1426
}
1527
]
1628
}

fluent-syntax/src/parser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Resource, Entry } from "./ast.js";
66
import { EOF, EOL, FluentParserStream } from "./stream.js";
77
import { ParseError } from "./errors.js";
88

9-
const trailingWSRe = /[ \t\n\r]+$/;
9+
const trailingWSRe = /[ \n\r]+$/;
1010

1111
type ParseFn<T> =
1212
// eslint-disable-next-line @typescript-eslint/no-explicit-any

fluent-syntax/test/fixtures_reference/tab.ftl

+7
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ key03 =
1212
key04 =
1313
This line is indented by 4 spaces,
1414
whereas this line by 1 tab.
15+
16+
# OK (value is a single tab)
17+
key05 =
18+
19+
# OK (attribute value is two tabs)
20+
key06 =
21+
.attr =

fluent-syntax/test/fixtures_reference/tab.json

+52-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,58 @@
6464
{
6565
"type": "Junk",
6666
"annotations": [],
67-
"content": "\twhereas this line by 1 tab.\n"
67+
"content": "\twhereas this line by 1 tab.\n\n"
68+
},
69+
{
70+
"type": "Message",
71+
"id": {
72+
"type": "Identifier",
73+
"name": "key05"
74+
},
75+
"value": {
76+
"type": "Pattern",
77+
"elements": [
78+
{
79+
"type": "TextElement",
80+
"value": "\t"
81+
}
82+
]
83+
},
84+
"attributes": [],
85+
"comment": {
86+
"type": "Comment",
87+
"content": "OK (value is a single tab)"
88+
}
89+
},
90+
{
91+
"type": "Message",
92+
"id": {
93+
"type": "Identifier",
94+
"name": "key06"
95+
},
96+
"value": null,
97+
"attributes": [
98+
{
99+
"type": "Attribute",
100+
"id": {
101+
"type": "Identifier",
102+
"name": "attr"
103+
},
104+
"value": {
105+
"type": "Pattern",
106+
"elements": [
107+
{
108+
"type": "TextElement",
109+
"value": "\t\t"
110+
}
111+
]
112+
}
113+
}
114+
],
115+
"comment": {
116+
"type": "Comment",
117+
"content": "OK (attribute value is two tabs)"
118+
}
68119
}
69120
]
70121
}

0 commit comments

Comments
 (0)