From 9f60467426d71419e767786c28bdd7fe86013289 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Fri, 3 Jul 2026 02:50:24 +0530 Subject: [PATCH] refactor(slack): extract _is_list_line helper for list-marker checks Deduplicate the '_BULLET_RE.match or _ORDERED_RE.match' idiom used at the list-run entry guard and the blank-line lookahead into a single helper, so adding future marker types is a one-point change. Pure refactor, no behavior change (22 block_kit tests still pass). --- plugins/platforms/slack/block_kit.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/platforms/slack/block_kit.py b/plugins/platforms/slack/block_kit.py index f3bcf1b9f..dc33aacbf 100644 --- a/plugins/platforms/slack/block_kit.py +++ b/plugins/platforms/slack/block_kit.py @@ -55,6 +55,11 @@ _QUOTE_RE = re.compile(r"^\s{0,3}>\s?(.*)$") _TABLE_SEP_RE = re.compile(r"^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)+\|?\s*$") +def _is_list_line(line: str) -> bool: + """True if ``line`` is a markdown list item (bullet or ordered).""" + return bool(_BULLET_RE.match(line) or _ORDERED_RE.match(line)) + + def _indent_level(spaces: str) -> int: """Map leading whitespace to a nesting level (2 spaces or 1 tab per level).""" width = 0 @@ -434,7 +439,7 @@ def render_blocks( continue # List group (bullets + ordered, with nesting) - if _BULLET_RE.match(line) or _ORDERED_RE.match(line): + if _is_list_line(line): flush_para() items: List[Tuple[int, bool, str]] = [] while i < n: @@ -463,7 +468,7 @@ def render_blocks( j = i + 1 while j < n and not lines[j].strip(): j += 1 - if j < n and (_BULLET_RE.match(lines[j]) or _ORDERED_RE.match(lines[j])): + if j < n and _is_list_line(lines[j]): i = j else: break