mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 14:25:00 +00:00
fix: Correct indentation in process_markdown function
This commit is contained in:
parent
d48d231349
commit
2f7e690966
1 changed files with 33 additions and 36 deletions
69
testsr.py
69
testsr.py
|
@ -21,48 +21,45 @@ def process_markdown(filename):
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if not section.strip(): # Ignore empty sections
|
if not section.strip(): # Ignore empty sections
|
||||||
continue
|
continue
|
||||||
# Extract the header (if present)
|
# Extract the header (if present)
|
||||||
header = section.split("\n")[0].strip()
|
header = section.split("\n")[0].strip()
|
||||||
# Get the content (everything after the header)
|
# Get the content (everything after the header)
|
||||||
content = "\n".join(section.split("\n")[1:]).strip()
|
content = "\n".join(section.split("\n")[1:]).strip()
|
||||||
|
|
||||||
for fence in all_fences:
|
for fence in all_fences:
|
||||||
if '\n' + fence[0] in content:
|
if '\n' + fence[0] in content:
|
||||||
break
|
break
|
||||||
|
|
||||||
# Process the content with find_original_update_blocks
|
# Process the content with find_original_update_blocks
|
||||||
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
|
# If an error occurs, add it to the results for this section
|
||||||
results.append({"header": header, "error": str(e)})
|
results.append({"header": header, "error": str(e)})
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Create a dictionary for this section
|
# Create a dictionary for this section
|
||||||
section_result = {"header": header, "blocks": []}
|
section_result = {"header": header, "blocks": []}
|
||||||
|
|
||||||
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
|
||||||
section_result["blocks"].append({"type": "shell", "content": block[1]})
|
section_result["blocks"].append({"type": "shell", "content": block[1]})
|
||||||
else: # This is a SEARCH/REPLACE block
|
else: # This is a SEARCH/REPLACE block
|
||||||
section_result["blocks"].append(
|
section_result["blocks"].append(
|
||||||
{
|
{
|
||||||
"type": "search_replace",
|
"type": "search_replace",
|
||||||
"filename": block[0],
|
"filename": block[0],
|
||||||
"original": block[1],
|
"original": block[1],
|
||||||
"updated": block[2],
|
"updated": block[2],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
results.append(section_result)
|
results.append(section_result)
|
||||||
|
|
||||||
# Output the results as JSON
|
# Output the results as JSON
|
||||||
print(json.dumps(results, indent=4))
|
print(json.dumps(results, indent=4))
|
||||||
|
|
||||||
except FileNotFoundError:
|
|
||||||
print(json.dumps({"error": f"File '{filename}' not found."}, indent=4))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue