fix: normalize open_tag whitespace in code block parser (#750)

This commit is contained in:
2026-04-17 05:33:24 +00:00
parent 6fbf5bb649
commit c69ae0e72b

View File

@@ -50,7 +50,11 @@ def normalize_code_block(match: re.Match) -> str:
normalized = "\n".join(lines)
return f"{open_tag}{normalized}\n{close_tag}"
# Normalize open_tag: strip trailing whitespace/newlines, add single newline
# The regex \s*\n can capture extra newlines in open_tag
clean_open = open_tag.rstrip() + "\n"
return f"{clean_open}{normalized}\n{close_tag}"
def process_line(line: str) -> tuple[str, int]: