Add renumber_all_blocks + fix sequential_numbering check for bold format

block_writer: new renumber_all_blocks() function that renumbers all
paragraphs across all blocks sequentially (1, 2, 3...). Handles both
plain "N." and bold "**N.**" formats. Added missing 'import re'.

qa_validator: sequential_numbering check now matches bold-formatted
numbers (**N.**) in addition to plain (N.).

Tested on Hecht: renumbered 115 paragraphs across 7 blocks, QA 6/6.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 12:30:31 +00:00
parent 7781987c3a
commit e438740ab4
2 changed files with 57 additions and 2 deletions

View File

@@ -279,8 +279,8 @@ def check_sequential_numbering(blocks: list[dict]) -> dict:
for block in blocks:
content = block.get("content", "")
# Find numbered paragraphs (e.g., "1.", "2.", "15.")
numbers = re.findall(r"^(\d+)\.", content, re.MULTILINE)
# Find numbered paragraphs: "1." or "**1.**" or "**1.**"
numbers = re.findall(r"^(?:\*\*)?(\d+)\.(?:\*\*)?", content, re.MULTILINE)
all_numbers.extend(int(n) for n in numbers)
if all_numbers: