Fix bug in update parser `pre' handling
authorJakob Cornell <jakob+gpg@jcornell.net>
Sun, 6 Nov 2022 16:24:05 +0000 (10:24 -0600)
committerJakob Cornell <jakob+gpg@jcornell.net>
Sun, 6 Nov 2022 16:35:13 +0000 (10:35 -0600)
strikebot/src/strikebot/tests.py
strikebot/src/strikebot/updates.py

index 8c8bd26e0d608f3ef90e5ae0cb0070c90944b032..d081e12eecfc34a35623d552858a30c61d350c0c 100644 (file)
@@ -52,3 +52,6 @@ class UpdateParsingTests(TestCase):
        def test_html_handling(self):
                pu = parse_update(_build_payload("123<hr>,456"), None, "")
                self.assertEqual(pu.number, 123)
+
+               pu = parse_update(_build_payload("<pre>123\n456</pre>"), None, "")
+               self.assertEqual(pu.number, 123)
index 48a1ee09835616477e042ff860b9c48a3f14c21c..2ecf1d70289758468b81216e7e2e587fa3406429 100644 (file)
@@ -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)):