Align comment parsing with Markdown
test / test (pull_request) Successful in 7s

Authored-By: Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
2026-08-27 17:01:29 +00:00
parent 8a1d71c4e9
commit 9c07c5f32d
2 changed files with 20 additions and 3 deletions
+11 -3
View File
@@ -23,12 +23,14 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
if (fence_char == "`" || fence_char == "~") {
while (substr(line, fence_pos + fence_run, 1) == fence_char) fence_run++
}
if (in_fence) {
if (!in_comment && in_fence) {
print line
if (fence_char == active_fence_char && fence_run >= active_fence_run) in_fence=0
next
}
if (fence_run >= 3) {
fence_info=substr(line, fence_pos + fence_run)
valid_fence_info=(fence_char == "~" || index(fence_info, "`") == 0)
if (!in_comment && fence_run >= 3 && valid_fence_info) {
in_fence=1
active_fence_char=fence_char
active_fence_run=fence_run
@@ -52,7 +54,13 @@ VISIBLE_BODY=$(printf '%s\n' "${BODY}" | awk '
continue
}
if (substr(line, pos, 1) == "`") {
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) {
ticks=1
while (substr(line, pos + ticks, 1) == "`") ticks++
close_pos=pos + ticks
+9
View File
@@ -150,6 +150,15 @@ check_contract "four-space indented backticks do not expose comments" \
check_contract "unequal backtick runs do not expose comments" \
$'`<!--``\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract "invalid backtick fence info does not expose comments" \
$'```html`oops\n<!--\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract "fences inside comments do not expose provenance" \
$'<!--\n```html\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract "escaped backticks do not hide a comment opener" \
$'\\`<!--\\`\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>\n-->' \
"$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section"
check_contract_pass "inline code containing comment opener stays visible" \
$'Use `<!--` when documenting an HTML comment opener.\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) <noreply@openai.com>' \
"$BASE" "$GOOD_HEAD"