fix(slack): keep blank-line-separated ordered items in one rich_text_list

When a Markdown ordered list has blank lines between items (common in
LLM-authored content), the list run loop breaks on each blank line.
Slack numbers each rich_text_list independently, so N items produce N
lists each starting at 1.

Skip blank lines inside the list run as soft separators instead of
breaking, so ordered items stay in one rich_text_list and Slack renders
the correct numbering.

Fixes #57076
This commit is contained in:
liuhao1024 2026-07-02 21:48:53 +08:00 committed by kshitij
parent 3a122ba4ac
commit d3c8a155cb
2 changed files with 20 additions and 0 deletions

View file

@ -451,6 +451,10 @@ def render_blocks(
indent, ordered, txt = items[-1]
items[-1] = (indent, ordered, txt + " " + lines[i].strip())
i += 1
elif not lines[i].strip():
# blank line — soft separator within a list run;
# skip so that ordered items stay in one rich_text_list.
i += 1
else:
break
blocks.append(_list_block(items))

View file

@ -90,6 +90,22 @@ class TestInlineFormatting:
]
assert styled, "expected a bold-styled text element in the list item"
def test_blank_line_separated_ordered_items_stay_in_one_list(self):
"""Regression: blank lines between ordered items must not reset numbering.
Slack numbers each rich_text_list independently. If blank lines break
the list run, N items produce N separate lists each starting at 1.
See: https://github.com/NousResearch/hermes-agent/issues/57076
"""
md = "1. alpha\n\n1. beta\n\n1. gamma"
blocks = render_blocks(md)
rich = [b for b in blocks if b["type"] == "rich_text"][0]
lists = [e for e in rich["elements"] if e["type"] == "rich_text_list"]
# Must be ONE list with 3 items, not 3 separate single-item lists
assert len(lists) == 1
items = lists[0]["elements"]
assert len(items) == 3
class TestTables:
def test_pipe_table_renders_native_table_block(self):