From 34988440fd09a3606defdbbf3daabf850ba4b369 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 4 Nov 2024 22:52:21 +0100 Subject: [PATCH] Remove redundant whitespace on end of line (for an even weird edge case) --- libpurple_to_markdown/markdown.py | 5 +++-- test/test_markdown_format.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libpurple_to_markdown/markdown.py b/libpurple_to_markdown/markdown.py index 0a1d7e0..b221f5e 100644 --- a/libpurple_to_markdown/markdown.py +++ b/libpurple_to_markdown/markdown.py @@ -15,10 +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'): + normalized = normalize_line(line) out.append('>') - if line: + if normalized: out.append(' ') - out.append(normalize_line(line)) + out.append(normalized) out.append('\n') del line out.append('\n') diff --git a/test/test_markdown_format.py b/test/test_markdown_format.py index cf46e1e..e4de7cc 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 \n\nWorld \n ' +TEXT_1 = 'Hello \n \nWorld \n ' EXPECTED_1 = """# Test