Authored-By: Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
@@ -41,9 +41,9 @@ elif ! RENDERED_BODY=$(printf '%s' "${BODY}" |
|
||||
FAILED=1
|
||||
fi
|
||||
|
||||
# A collapsed disclosure is valid supporting content, but provenance inside one
|
||||
# is not visible by default. Remove only collapsed details subtrees; an open
|
||||
# disclosure remains visible unless one of its ancestors is collapsed.
|
||||
# Remove rendered subtrees that aren't visible by default. An open disclosure
|
||||
# remains visible unless one of its ancestors is hidden; media fallback content
|
||||
# is hidden when the browser supports the containing element.
|
||||
VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" |
|
||||
awk '
|
||||
{
|
||||
@@ -54,20 +54,28 @@ VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" |
|
||||
tag=tag char
|
||||
if (char == ">") {
|
||||
lower=tolower(tag)
|
||||
if (lower ~ /^<details([[:space:]>])/) {
|
||||
opening=lower
|
||||
sub(/^</, "", opening)
|
||||
sub(/[[:space:]>].*$/, "", opening)
|
||||
closing=lower
|
||||
sub(/^<\//, "", closing)
|
||||
sub(/[[:space:]>].*$/, "", closing)
|
||||
if (opening ~ /^(details|audio|video|canvas|object)$/) {
|
||||
attributes=lower
|
||||
gsub(/"[^"]*"/, "", attributes)
|
||||
parent_hidden=(details_depth > 0 && hidden[details_depth])
|
||||
details_depth++
|
||||
hidden[details_depth]=(parent_hidden || attributes !~ /[[:space:]]open([[:space:]=>]|$)/)
|
||||
parent_hidden=(container_depth > 0 && hidden[container_depth])
|
||||
container_depth++
|
||||
container[container_depth]=opening
|
||||
hidden[container_depth]=(parent_hidden || opening != "details" || attributes !~ /[[:space:]]open([[:space:]=>]|$)/)
|
||||
}
|
||||
else if (lower ~ /^<\/details([[:space:]>])/) {
|
||||
if (details_depth > 0) {
|
||||
delete hidden[details_depth]
|
||||
details_depth--
|
||||
else if (closing ~ /^(details|audio|video|canvas|object)$/) {
|
||||
if (container_depth > 0 && container[container_depth] == closing) {
|
||||
delete container[container_depth]
|
||||
delete hidden[container_depth]
|
||||
container_depth--
|
||||
}
|
||||
}
|
||||
else if (!hidden[details_depth]) printf "%s", tag
|
||||
else if (!hidden[container_depth]) printf "%s", tag
|
||||
in_tag=0
|
||||
tag=""
|
||||
}
|
||||
@@ -76,7 +84,7 @@ VISIBLE_BODY=$(printf '%s\n' "${RENDERED_BODY}" |
|
||||
in_tag=1
|
||||
tag=char
|
||||
}
|
||||
else if (!hidden[details_depth]) printf "%s", char
|
||||
else if (!hidden[container_depth]) printf "%s", char
|
||||
}
|
||||
}
|
||||
')
|
||||
|
||||
Reference in New Issue
Block a user