From 68d22249c0b27439932d3dc5d0d76a9f0b2dcec6 Mon Sep 17 00:00:00 2001 From: Jakob Cornell Date: Sun, 25 Sep 2022 23:33:48 -0500 Subject: [PATCH] Add update parsing support for h3 elements and up --- strikebot/setup.cfg | 2 +- strikebot/src/strikebot/updates.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/strikebot/setup.cfg b/strikebot/setup.cfg index 29e5900..c22a71f 100644 --- a/strikebot/setup.cfg +++ b/strikebot/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = strikebot -version = 0.0.2 +version = 0.0.3 [options] package_dir = diff --git a/strikebot/src/strikebot/updates.py b/strikebot/src/strikebot/updates.py index e3f58cd..5e5d73d 100644 --- a/strikebot/src/strikebot/updates.py +++ b/strikebot/src/strikebot/updates.py @@ -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() -- 2.30.2