diff --git a/check.sh b/check.sh index d6b1b75..f04b634 100755 --- a/check.sh +++ b/check.sh @@ -42,7 +42,8 @@ elif ! RENDERED_BODY=$(printf '%s' "${BODY}" | fi # A collapsed disclosure is valid supporting content, but provenance inside one -# is not visible by default. Remove details subtrees before locating sections. +# is not visible by default. Remove only collapsed details subtrees; an open +# disclosure remains visible unless one of its ancestors is collapsed. VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" | awk ' { @@ -53,11 +54,18 @@ VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" | tag=tag char if (char == ">") { lower=tolower(tag) - if (lower ~ /^])/) details_depth++ - else if (lower ~ /^<\/details([[:space:]>])/) { - if (details_depth > 0) details_depth-- + if (lower ~ /^])/) { + parent_hidden=(details_depth > 0 && hidden[details_depth]) + details_depth++ + hidden[details_depth]=(parent_hidden || lower !~ /[[:space:]]open([[:space:]=>]|$)/) } - else if (details_depth == 0) printf "%s", tag + else if (lower ~ /^<\/details([[:space:]>])/) { + if (details_depth > 0) { + delete hidden[details_depth] + details_depth-- + } + } + else if (!hidden[details_depth]) printf "%s", tag in_tag=0 tag="" } @@ -66,7 +74,7 @@ VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" | in_tag=1 tag=char } - else if (details_depth == 0) printf "%s", char + else if (!hidden[details_depth]) printf "%s", char } } ') diff --git a/tests/bin/curl b/tests/bin/curl index 63b420a..6ac3373 100755 --- a/tests/bin/curl +++ b/tests/bin/curl @@ -62,7 +62,8 @@ printf '%s\n' "${PR_BODY}" | awk ' next } if (lower ~ /^[ ]{0,3}])/) { - print "
" + if (lower ~ /[[:blank:]]open([[:blank:]=>]|$)/) print "
" + else print "
" next } if (line ~ /^## Tracking[[:space:]]*$/) print "

Tracking

" diff --git a/tests/run b/tests/run index 6ac70af..15246a2 100755 --- a/tests/run +++ b/tests/run @@ -179,6 +179,12 @@ check_contract_pass "fenced code examples remain available" \ check_contract "details cannot collapse provenance" \ $'
Release notes\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) \n
' \ "$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section" +check_contract_pass "open details preserve visible provenance" \ + $'
Release notes\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) \n
' \ + "$BASE" "$GOOD_HEAD" +check_contract "open details inside collapsed details remain hidden" \ + $'
Release notes\n
Visible only after expansion\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) \n
\n
' \ + "$BASE" "$GOOD_HEAD" "PR body must contain a non-empty ## Tracking section" check_contract_pass "unrelated collapsed details remain available" \ $'
Logs\n\nSupporting output\n
\n\n## Tracking\n- Fixes bug-x7k2m9 — https://agenthub.fritzlab.net/bug-x7k2m9\n\n## Attribution\n- Authored-By: Codex (GPT-5) ' \ "$BASE" "$GOOD_HEAD"