From 3793a49f8359dccd98395e6e85e54a9df0f5a2c2 Mon Sep 17 00:00:00 2001 From: Jakob Cornell Date: Sun, 6 Nov 2022 10:24:05 -0600 Subject: [PATCH] Fix bug in update parser `pre' handling --- strikebot/src/strikebot/tests.py | 3 +++ strikebot/src/strikebot/updates.py | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/strikebot/src/strikebot/tests.py b/strikebot/src/strikebot/tests.py index 8c8bd26..d081e12 100644 --- a/strikebot/src/strikebot/tests.py +++ b/strikebot/src/strikebot/tests.py @@ -52,3 +52,6 @@ class UpdateParsingTests(TestCase): def test_html_handling(self): pu = parse_update(_build_payload("123
,456"), None, "") self.assertEqual(pu.number, 123) + + pu = parse_update(_build_payload("
123\n456
"), None, "") + self.assertEqual(pu.number, 123) diff --git a/strikebot/src/strikebot/updates.py b/strikebot/src/strikebot/updates.py index 48a1ee0..2ecf1d7 100644 --- a/strikebot/src/strikebot/updates.py +++ b/strikebot/src/strikebot/updates.py @@ -55,9 +55,8 @@ def parse_update(payload_data: dict, curr_count: Optional[int], bot_user: str) - worklist.extend(reversed(el.contents)) worklist.append(NEW_LINE) elif el.name == "pre": - worklist.append(NEW_LINE) - worklist.extend([l for l in reversed(el.text.splitlines())]) - worklist.append(NEW_LINE) + out.extend([l] for l in el.text.splitlines()) + out.append([]) elif el.name == "tr": worklist.append(NEW_LINE) for (i, cell) in enumerate(reversed(el.contents)): -- 2.30.2