fix: Correct newline escaping in normalize script (#750)
This commit is contained in:
@@ -33,14 +33,11 @@ def normalize_code_block(match: re.Match) -> str:
|
||||
code = match.group("code")
|
||||
close_tag = match.group("close")
|
||||
|
||||
# Skip empty blocks
|
||||
if not code.strip():
|
||||
return match.group(0)
|
||||
|
||||
# Dedent the code
|
||||
dedented = textwrap.dedent(code)
|
||||
|
||||
# Strip leading/trailing blank lines
|
||||
lines = dedented.split("\n")
|
||||
while lines and not lines[0].strip():
|
||||
lines.pop(0)
|
||||
@@ -82,7 +79,7 @@ def process_file(filepath: str, dry_run: bool = False) -> dict:
|
||||
"""Process a single JSONL file. Returns stats dict."""
|
||||
path = Path(filepath)
|
||||
if not path.exists():
|
||||
return {"file": filepath, "error": "not found", "fixes": 0, "lines": 0}
|
||||
return {"file": str(filepath), "error": "not found", "fixes": 0, "lines": 0}
|
||||
|
||||
lines = path.read_text(encoding="utf-8").splitlines()
|
||||
fixed_lines = []
|
||||
@@ -100,7 +97,7 @@ def process_file(filepath: str, dry_run: bool = False) -> dict:
|
||||
path.write_text("\n".join(fixed_lines) + "\n", encoding="utf-8")
|
||||
|
||||
return {
|
||||
"file": filepath,
|
||||
"file": str(filepath),
|
||||
"lines": len(lines),
|
||||
"fixes": total_fixes,
|
||||
"changed": total_fixes > 0,
|
||||
|
||||
Reference in New Issue
Block a user