fix: Handle errors in processing Markdown sections

This commit is contained in:
Paul Gauthier 2024-08-22 09:01:04 -07:00 committed by Paul Gauthier (aider)
parent 8ec67d339d
commit 882cf676b9

View file

@ -33,7 +33,6 @@ def process_markdown(filename):
# Split the content into sections based on '####' headers # Split the content into sections based on '####' headers
sections = re.split(r"(?=####\s)", content) sections = re.split(r"(?=####\s)", content)
results = []
for section in sections: for section in sections:
if "editblock_coder.py" in section or "test_editblock.py" in section: if "editblock_coder.py" in section or "test_editblock.py" in section:
continue continue
@ -53,10 +52,13 @@ def process_markdown(filename):
try: try:
blocks = list(find_original_update_blocks(content, fence)) blocks = list(find_original_update_blocks(content, fence))
except ValueError as e: except ValueError as e:
# If an error occurs, add it to the results for this section print("***", header, "*" * 20)
results.append({"header": header, "error": str(e)}) print(str(e))
continue continue
if blocks:
print("***", header, "*" * 20)
for block in blocks: for block in blocks:
if block[0] is None: # This is a shell command block if block[0] is None: # This is a shell command block
print("*** SHELL", "*" * 20) print("*** SHELL", "*" * 20)
@ -65,7 +67,6 @@ def process_markdown(filename):
else: # This is a SEARCH/REPLACE block else: # This is a SEARCH/REPLACE block
print("*** SEARCH:", block[0], "*" * 20) print("*** SEARCH:", block[0], "*" * 20)
print("***", header, "*" * 20)
print(block[1], end="") print(block[1], end="")
print("*" * 20) print("*" * 20)
print(block[2], end="") print(block[2], end="")