Skip to content

Commit 61328fa

Browse files
authored
Treat tab as text, not whitespace (#179)
1 parent 4c38856 commit 61328fa

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

fluent.syntax/fluent/syntax/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def dedent(self, elements, common_indent):
439439
# Trim trailing whitespace from the Pattern.
440440
last_element = trimmed[-1] if len(trimmed) > 0 else None
441441
if isinstance(last_element, ast.TextElement):
442-
last_element.value = last_element.value.rstrip(' \t\n\r')
442+
last_element.value = last_element.value.rstrip(' \n\r')
443443
if last_element.value == "":
444444
trimmed.pop()
445445

fluent.syntax/tests/syntax/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/tests/syntax/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)