Add update parsing support for h3 elements and up
authorJakob Cornell <jakob+gpg@jcornell.net>
Mon, 26 Sep 2022 04:33:48 +0000 (23:33 -0500)
committerJakob Cornell <jakob+gpg@jcornell.net>
Mon, 26 Sep 2022 04:33:48 +0000 (23:33 -0500)
strikebot/setup.cfg
strikebot/src/strikebot/updates.py

index 29e5900e48483cd7f36a24ac63d59384aeaaf6d9..c22a71f6b741382ec4551b2eb757e032eabf6d9a 100644 (file)
@@ -1,6 +1,6 @@
 [metadata]
 name = strikebot
-version = 0.0.2
+version = 0.0.3
 
 [options]
 package_dir =
index e3f58cd477b2e976b44e7674d563ba8bcbcb3ba7..5e5d73d4ebef755cc6b3854eb0c49401eafd600f 100644 (file)
@@ -50,7 +50,7 @@ def parse_update(payload_data: dict, curr_count: Optional[int], bot_user: str) -
                        worklist.extend(reversed(el.contents))
                elif el.name in ["ul", "ol", "table", "thead", "tbody"]:
                        worklist.extend(reversed(el.contents))
-               elif el.name in ["li", "p", "div", "h1", "h2", "blockquote"]:
+               elif el.name in ["li", "p", "div", "blockquote"] or re.match(r"h[1-6]$", el.name):
                        worklist.append(NEW_LINE)
                        worklist.extend(reversed(el.contents))
                        worklist.append(NEW_LINE)
@@ -66,7 +66,7 @@ def parse_update(payload_data: dict, curr_count: Optional[int], bot_user: str) -
                                        worklist.append(SPACE)
                        worklist.append(NEW_LINE)
                else:
-                       raise RuntimeError(f"can't parse tag {el.tag}")
+                       raise RuntimeError(f"can't parse tag {el.name}")
 
        tmp_lines = (
                "".join(" " if part is SPACE else part for part in parts).strip()