Fix removing empty elements to avoid trailing commas

This commit is contained in:
relhamdi
2026-05-25 11:17:50 +02:00
parent d6f5be3bb4
commit 2f1507c31a
3 changed files with 7 additions and 3 deletions
+2 -1
View File
@@ -60,7 +60,8 @@ def parse_options(raw: str) -> list[str]:
# Generate cartesian product
for combo in product(*current_block):
result.append(", ".join(combo))
parts = [p for p in combo if p.strip()]
result.append(", ".join(parts) if parts else "")
elif stripped == "---":
if in_combine:
+3 -1
View File
@@ -43,8 +43,10 @@ def test_combine_three_lists():
def test_combine_empty_line_in_list():
raw = "@combine\na\n\n---\nb\n@end"
result = parse_options(raw)
assert ", b" in result # empty + b
assert "b" in result
assert "a, b" in result
# Empty element combined with b gives just "b"
assert ", b" not in result
def test_multiple_combine_blocks():
+2 -1
View File
@@ -75,7 +75,8 @@ const parseOptions = (raw) => {
const next = [];
for (const a of acc) {
for (const b of list) {
next.push(a ? `${a}, ${b}` : b);
const parts = [a, b].filter((p) => p.trim() !== "");
next.push(parts.join(", "));
}
}
return next;