Keep escape parsing linear
test / test (pull_request) Successful in 6s

Authored-By: Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
2026-08-27 17:05:40 +00:00
parent 9c07c5f32d
commit 5ce83cdf13
+9 -8
View File
@@ -40,6 +40,7 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
visible=""
pos=1
backslash_run=0
while (pos <= length(line)) {
if (in_comment) {
rest=substr(line, pos)
@@ -51,16 +52,11 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
visible=visible " "
pos += comment_end + 2
in_comment=0
backslash_run=0
continue
}
escaped=0
escape_pos=pos - 1
while (escape_pos >= 1 && substr(line, escape_pos, 1) == "\\") {
escaped++
escape_pos--
}
if (substr(line, pos, 1) == "`" && escaped % 2 == 0) {
if (substr(line, pos, 1) == "`" && backslash_run % 2 == 0) {
ticks=1
while (substr(line, pos + ticks, 1) == "`") ticks++
close_pos=pos + ticks
@@ -77,6 +73,7 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
if (found_close) {
visible=visible substr(line, pos, close_pos + ticks - pos)
pos=close_pos + ticks
backslash_run=0
continue
}
}
@@ -85,9 +82,13 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
visible=visible " "
in_comment=1
pos += 4
backslash_run=0
continue
}
visible=visible substr(line, pos, 1)
char=substr(line, pos, 1)
visible=visible char
if (char == "\\") backslash_run++
else backslash_run=0
pos++
}
print visible