Skip to content

Commit 94f379a

Browse files
authored
Merge pull request #6 from mgifford/copilot/fix-accessibility-main-landmark
Add main landmark for WCAG 2.1 compliance
2 parents e312a7d + be67501 commit 94f379a

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<div class="clock"></div>
2929
<section aria-live="assertive" aria-label="Slide mode status">Leaving slide mode.</section>
3030

31+
<main>
3132
<!-- Slide 1: Cover -->
3233
<section class="slide cover clear" id="cover" aria-label="Cover: Whisper Live Captioning Demo">
3334
<h1>Whisper Live Captioning Demo</h1>
@@ -149,6 +150,7 @@ <h3 class="small">Transcript</h3>
149150
</div>
150151
<div class="notes" hidden>Separate element ID to allow multi-box polling later, if needed.</div>
151152
</section>
153+
</main>
152154

153155
</body>
154156
</html>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
"test:html": "html-validate -c .htmlvalidate.json '*.html'",
1010
"test:a11y": "pa11y-ci --config .pa11yci.json || true",
1111
"test:headings": "node scripts/test-heading-order.js",
12+
"test:main-landmark": "bash scripts/check-main-landmark.sh",
1213
"test:links": "bash scripts/check-links.sh",
1314
"test:spell": "cspell '**/*.{md,html,js,css}' || true",
1415
"test:css": "bash scripts/validate-css.sh",
15-
"test:all": "npm run test:html && npm run test:headings && npm run test:css && npm run test:links && npm run test:spell",
16+
"test:all": "npm run test:html && npm run test:css && npm run test:main-landmark && npm run test:links && npm run test:spell",
1617
"test": "npm run test:all"
1718
},
1819
"repository": {

scripts/check-main-landmark.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# Test to ensure index.html has exactly one main landmark element
3+
# This prevents regression of the accessibility issue where main landmark was missing
4+
5+
set -e
6+
7+
echo "🔍 Checking for main landmark in index.html..."
8+
9+
# Count the number of opening main tags
10+
MAIN_OPEN_COUNT=$(grep -c "<main>" index.html || true)
11+
12+
# Count the number of closing main tags
13+
MAIN_CLOSE_COUNT=$(grep -c "</main>" index.html || true)
14+
15+
if [ "$MAIN_OPEN_COUNT" -eq 0 ]; then
16+
echo "❌ FAIL: No <main> element found in index.html"
17+
exit 1
18+
elif [ "$MAIN_OPEN_COUNT" -gt 1 ]; then
19+
echo "❌ FAIL: Multiple <main> opening tags found ($MAIN_OPEN_COUNT)"
20+
exit 1
21+
fi
22+
23+
if [ "$MAIN_CLOSE_COUNT" -eq 0 ]; then
24+
echo "❌ FAIL: No </main> closing tag found in index.html"
25+
exit 1
26+
elif [ "$MAIN_CLOSE_COUNT" -gt 1 ]; then
27+
echo "❌ FAIL: Multiple </main> closing tags found ($MAIN_CLOSE_COUNT)"
28+
exit 1
29+
fi
30+
31+
if [ "$MAIN_OPEN_COUNT" -ne "$MAIN_CLOSE_COUNT" ]; then
32+
echo "❌ FAIL: Mismatched <main> tags (opening: $MAIN_OPEN_COUNT, closing: $MAIN_CLOSE_COUNT)"
33+
exit 1
34+
fi
35+
36+
echo "✅ PASS: Exactly one <main> landmark found with matching opening and closing tags"
37+
echo "✅ Main landmark test passed!"

0 commit comments

Comments
 (0)