Skip to content

Commit 473fd9d

Browse files
authored
fix some whitespace issues when formatting a
string field for a conf file
1 parent 0862bc6 commit 473fd9d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

contentctl/output/conf_writer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ def escapeNewlines(obj:Any):
3434
# Failing to do so will result in an improperly formatted conf files that
3535
# cannot be parsed
3636
if isinstance(obj,str):
37-
return obj.replace(f"\n"," \\\n")
37+
# Remove leading and trailing characters. Conf parsers may erroneously
38+
# Parse fields if they have leading or trailing newlines/whitespace and we
39+
# probably don't want that anyway as it doesn't look good in output
40+
return obj.strip().replace(f"\n"," \\\n")
3841
else:
3942
return obj
4043

0 commit comments

Comments
 (0)