From 64eb26be3fab161a03b8118c35f1e50327a088c5 Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Thu, 19 Jan 2023 10:24:37 -0600 Subject: [PATCH] fixed line ending conversion for windows --- src/djlint/reformat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/djlint/reformat.py b/src/djlint/reformat.py index a316b0b..fb5afd9 100644 --- a/src/djlint/reformat.py +++ b/src/djlint/reformat.py @@ -36,7 +36,8 @@ def reformat_file(config: Config, this_file: Path) -> dict: # preserve original line endings line_ending = rawcode.find("\n") if line_ending > -1 and rawcode[max(line_ending - 1, 0)] == "\r": - beautified_code = beautified_code.replace("\n", "\r\n") + # convert \r?\n to \r\n + beautified_code = beautified_code.replace("\r", "").replace("\n", "\r\n") if config.check is not True or config.stdin is True: this_file.write_bytes(beautified_code.encode("utf8"))