chore: fix fences errors

This commit is contained in:
Jesús Pérez 2026-01-14 05:26:18 +00:00
parent 59eea6d232
commit ceffb434fe
Signed by: jesus
GPG Key ID: 9F243E355E0BC939
2 changed files with 7 additions and 9 deletions

View File

@ -68,7 +68,7 @@ def main [
# Phase 0: Fix literal \n escape sequences (Nushell - SAFE) # Phase 0: Fix literal \n escape sequences (Nushell - SAFE)
if ($phase == "newlines" or $phase == "all") { if ($phase == "newlines" or $phase == "all") {
if ($modified_content | str contains '\\n') { if ($modified_content | str contains '\n') {
let newlines_result = fix-literal-newlines $modified_content let newlines_result = fix-literal-newlines $modified_content
$newlines_fixed = $newlines_result.fixed_count $newlines_fixed = $newlines_result.fixed_count
$total_newlines_fixed += $newlines_fixed $total_newlines_fixed += $newlines_fixed
@ -142,20 +142,18 @@ def main [
# Fix literal \n escape sequences → actual newlines # Fix literal \n escape sequences → actual newlines
def fix-literal-newlines [content] { def fix-literal-newlines [content] {
{ {
content: ($content | str replace -a '\\n' "\n") content: ($content | str replace -a '\n' "\n")
fixed_count: 1 fixed_count: 1
} }
} }
# Clean up corrupted {$detected_lang} literals only (preserve structure and blanks) # Clean up corrupted {$detected_lang} literals only (preserve structure and blanks)
def cleanup-corrupted-fences [content] { def cleanup-corrupted-fences [content] {
# Only fix corrupted opening fences with {$detected_lang} let had_corruption = $content | str contains '```{$detected_lang}'
# Replace them with clean ``` (without language tag so they can be detected later) let fixed_content = $content | str replace -a '```{$detected_lang}' '```'
{ {
content: ($content | str replace -a '```{$detected_lang}' '```') content: $fixed_content
fixed_count: ( fixed_count: (if $had_corruption { 1 } else { 0 })
$content | str collect | if ($content | str contains '```{$detected_lang}') { 1 } else { 0 }
)
} }
} }