v0.5.4
NewPromt - small fix
This commit is contained in:
+11
-3
@@ -216,12 +216,20 @@ def emit_markdown(blocks: list[Block], *, emit_page_breaks: bool = False) -> str
|
||||
continue
|
||||
|
||||
if isinstance(b, ListBlock):
|
||||
for idx, item in enumerate(b.items, start=1):
|
||||
levels = b.item_levels or []
|
||||
counters = [0] * 10
|
||||
for idx, item in enumerate(b.items):
|
||||
level = levels[idx] if idx < len(levels) else 1
|
||||
level = max(1, min(level, 9))
|
||||
body = escape_md_inline(item)
|
||||
indent = " " * (level - 1)
|
||||
if b.ordered:
|
||||
chunks.append(f"{idx}. {body}")
|
||||
counters[level - 1] += 1
|
||||
for deeper in range(level, 10):
|
||||
counters[deeper] = 0
|
||||
chunks.append(f"{indent}{counters[level - 1]}. {body}")
|
||||
else:
|
||||
chunks.append(f"- {body}")
|
||||
chunks.append(f"{indent}- {body}")
|
||||
chunks.append("")
|
||||
i += 1
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user