From d83f8cc7fc52bcc33b186e9a133aeba21ddaa06f Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 4 Nov 2024 22:49:26 +0100 Subject: [PATCH] Remove redundant whitespace on end of line --- libpurple_to_markdown/markdown.py | 6 +++++- test/test_markdown_format.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libpurple_to_markdown/markdown.py b/libpurple_to_markdown/markdown.py index 65536b5..0a1d7e0 100644 --- a/libpurple_to_markdown/markdown.py +++ b/libpurple_to_markdown/markdown.py @@ -15,7 +15,11 @@ def format_message_as_citation(out: list[str], msg: Message) -> None: out.append(f'{msg.sent_at.date()} {msg.sent_at.time()} [[{msg.sender}]]:') out.append('\n') for line in msg.text.strip().split('\n'): - out.append(f'> {normalize_line(line)}\n') + out.append('>') + if line: + out.append(' ') + out.append(normalize_line(line)) + out.append('\n') del line out.append('\n') diff --git a/test/test_markdown_format.py b/test/test_markdown_format.py index 9cebc79..cf46e1e 100644 --- a/test/test_markdown_format.py +++ b/test/test_markdown_format.py @@ -6,7 +6,7 @@ from libpurple_to_markdown.markdown import format_messages NOW = datetime.datetime.fromtimestamp(1_000_000_000, tz=datetime.UTC) -TEXT_1 = 'Hello \nWorld \n ' +TEXT_1 = 'Hello \n\nWorld \n ' EXPECTED_1 = """# Test @@ -15,10 +15,12 @@ EXPECTED_1 = """# Test 2001-09-09 01:46:40 [[Test Sender]]: > Hello +> > World 2001-09-09 01:46:40 [[Test Sender]]: > Hello +> > World """