From: Jakob Cornell Date: Mon, 26 Sep 2022 04:33:48 +0000 (-0500) Subject: Add update parsing support for h3 elements and up X-Git-Tag: strikebot-0.0.7~21 X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=68d22249c0b27439932d3dc5d0d76a9f0b2dcec6;p=counting.git Add update parsing support for h3 elements and up --- 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()