Skip to content

Editorial diagram design for Claude Code, Codex, GitHub Copilot, Cursor, Factory Droid, Qoder, and Pi. 45 diagram types. Self-contained HTML + SVG. No shadows. No Mermaid slop.

fix(motion): exempt decorative SVGs from diagram naming checks (#330)

Rudy Mizrahi Celekli2f2774832b7a
diff --git a/README.md b/README.md
index a1fe31b..f712633 100644
--- a/README.md
+++ b/README.md
@@ -533,7 +533,7 @@ This keeps the agent's working context tight: routine diagrams load one type ref
Before submitting a new example, run `python3 scripts/lint-skin.py <your-new-example.html>`.
The repository-wide check `python3 scripts/lint-skin.py --all --baseline` covers examples and templates and must stay green.
-CI separately verifies semantic routing, animated-example structure, animated skin, every shipped motion asset, and adversarial mutations of the controller contract, reporting later gate outcomes even when an earlier gate fails. Semantic routing must pass `python3 scripts/verify-semantic-motion.py --markdown-only`; the animated example has a separate `--example-only` gate. Every shipped motion template/example must also pass `python3 scripts/verify-motion.py --shipped`.
+CI separately verifies semantic routing, animated-example structure, animated skin, every shipped motion asset, and adversarial mutations of the controller contract, reporting later gate outcomes even when an earlier gate fails. Semantic routing must pass `python3 scripts/verify-semantic-motion.py --markdown-only`; the animated example has a separate `--example-only` gate. Every shipped motion template/example must also pass `python3 scripts/verify-motion.py --shipped`. Both motion verifiers exempt root SVGs marked `aria-hidden="true"` from diagram naming checks; decorative icons never replace the required accessible diagram.
The linter's `a11y` category rejects diagram SVGs without a resolving accessible name,
an empty or misplaced title/description, or unsafe bare `title` / `desc` IDs. It also pins the exact reviewed motion controller and rejects remote assets, CSS `@import`, non-fragment CSS `url()`, and executable attributes such as `onclick` or `srcdoc`.
If you touch the draw.io import path, `python3 scripts/verify-drawio-import.py` must also pass —
diff --git a/scripts/test-verify-motion.py b/scripts/test-verify-motion.py
index 57b6d91..5a10ce4 100644
--- a/scripts/test-verify-motion.py
+++ b/scripts/test-verify-motion.py
@@ -85,6 +85,13 @@ def main() -> int:
print(f"OK: {name} rejected — {expected}")
check("canonical-template", source, None)
+ decorative = ('<svg aria-hidden="true" focusable="false" viewBox="0 0 12 12">'
+ '<path d="M2 2 L10 2 L10 10 L2 10 Z"/></svg>')
+ check("decorative-header-icon", source.replace("<body>", "<body>" + decorative, 1), None)
+ check("only-decorative-svgs", source.replace('<svg ', '<svg aria-hidden="true" ', 1),
+ "motion document needs an accessible SVG")
+ check("unnamed-accessible-header-icon", source.replace("<body>",
+ "<body>" + decorative.replace(' aria-hidden="true"', ''), 1), "needs role=img")
script_free_none = re.sub(
r"<script\b[^>]*>.*?</script\s*>", "", source, flags=re.IGNORECASE | re.DOTALL
)
diff --git a/scripts/test-verify-semantic-motion.py b/scripts/test-verify-semantic-motion.py
index 68789e7..f64e0c3 100644
--- a/scripts/test-verify-semantic-motion.py
+++ b/scripts/test-verify-semantic-motion.py
@@ -353,6 +353,47 @@ def main() -> int:
raise AssertionError(f"duplicate id was accepted: {errors}")
print("OK: duplicate HTML/SVG id in the animated example is rejected")
+ with tempfile.TemporaryDirectory(prefix="verify-semantic-motion-decorative-") as temp_dir:
+ source = module.EXAMPLE.read_text(encoding="utf-8")
+ icon = ('<svg aria-hidden="true" focusable="false" viewBox="0 0 12 12">'
+ '<path d="M2 2 L10 2 L10 10 L2 10 Z"/></svg>')
+ for label, html, expected in (
+ ("decorative icon", source.replace("<body>", "<body>" + icon, 1), None),
+ ("only decorative SVG", source.replace('<svg ', '<svg aria-hidden="true" ', 1),
+ "expected one accessible SVG"),
+ ("extra accessible icon", source.replace("<body>",
+ "<body>" + icon.replace(' aria-hidden="true"', ''), 1),
+ "expected one accessible SVG"),
+ ):
+ candidate = Path(temp_dir) / "candidate.html"
+ candidate.write_text(html, encoding="utf-8")
+ errors = module.verify_example(candidate)
+ if (expected is None and errors) or (expected and not any(expected in e for e in errors)):
+ raise AssertionError(f"{label}: unexpected result {errors}")
+ print(f"OK: {label}")
+
+ # A nested decorative viewport must not replace its outer naming record.
+ with tempfile.TemporaryDirectory(prefix="verify-semantic-motion-nested-") as temp_dir:
+ source = module.EXAMPLE.read_text(encoding="utf-8")
+ start = source.index("<desc ")
+ end = source.index("</desc>", start) + len("</desc>")
+ description = source[start:end]
+ without_desc = source[:start] + source[end:]
+ icon = ('<svg aria-hidden="true" focusable="false" viewBox="0 0 12 12">'
+ '<title>Decorative icon</title><desc>Icon only</desc>'
+ '<path d="M2 2 L10 2 L10 10 L2 10 Z"/></svg>')
+ for label, html, expected in (
+ ("late outer description", without_desc.replace("</svg>", icon + description + "</svg>", 1), None),
+ ("missing outer description", without_desc.replace("</svg>", icon + "</svg>", 1),
+ "description must be non-empty"),
+ ):
+ candidate = Path(temp_dir) / "candidate.html"
+ candidate.write_text(html, encoding="utf-8")
+ errors = module.verify_example(candidate)
+ if (expected is None and errors) or (expected and not any(expected in e for e in errors)):
+ raise AssertionError(f"{label}: unexpected result {errors}")
+ print(f"OK: {label}")
+
print("All semantic-motion verifier tests passed.")
return 0
diff --git a/scripts/verify-motion.py b/scripts/verify-motion.py
index ec1e06f..c905dff 100644
--- a/scripts/verify-motion.py
+++ b/scripts/verify-motion.py
@@ -469,9 +469,11 @@ def verify(path: Path) -> list[str]:
if mode == "loop" and len(parser.items) > 2:
errors.append("loop mode may contain at most one semantic item and one decorative token")
- if not parser.svgs:
+ checkable = [svg for svg in parser.svgs
+ if str(svg["attrs"].get("aria-hidden", "")).casefold() != "true"]
+ if not checkable:
errors.append("motion document needs an accessible SVG")
- for number, svg in enumerate(parser.svgs, 1):
+ for number, svg in enumerate(checkable, 1):
attrs = svg["attrs"]
assert isinstance(attrs, dict)
if attrs.get("role") != "img":
diff --git a/scripts/verify-semantic-motion.py b/scripts/verify-semantic-motion.py
index 85f1e46..819dbe4 100644
--- a/scripts/verify-semantic-motion.py
+++ b/scripts/verify-semantic-motion.py
@@ -145,7 +145,7 @@ class ContractParser(HTMLParser):
if not allowed_font:
self.remote_assets.append((tag, value))
- if tag == "svg":
+ if tag == "svg" and self._svg_depth == 0:
self._svg_depth = 1
self._current_svg = {
"attrs": data,
@@ -495,10 +495,12 @@ def verify_example(path: Path = EXAMPLE) -> list[str]:
if steps != [1, 2, 3, 4, 5]:
errors.append(f"policy steps must be exactly [1, 2, 3, 4, 5]; found {steps}")
- if len(parser.svgs) != 1:
- errors.append(f"expected one SVG; found {len(parser.svgs)}")
+ checkable = [svg for svg in parser.svgs
+ if str(svg["attrs"].get("aria-hidden", "")).casefold() != "true"]
+ if len(checkable) != 1:
+ errors.append(f"expected one accessible SVG; found {len(checkable)}")
else:
- svg = parser.svgs[0]
+ svg = checkable[0]
attrs = svg["attrs"]
title = svg["title"]
desc = svg["desc"]
diff --git a/skills/diagram-design/references/animation.md b/skills/diagram-design/references/animation.md
index bc642b9..150c718 100644
--- a/skills/diagram-design/references/animation.md
+++ b/skills/diagram-design/references/animation.md
@@ -122,7 +122,7 @@ python3 scripts/test-verify-motion.py
python3 scripts/lint-skin.py path/to/animated-diagram.html
```
-The verifier checks mode/state declarations, contiguous steps, motion budgets, complete SVG naming, no-JS source visibility, decorative accessibility, the full control set, live status, reduced-motion/print CSS, keyboard handling, page-hide pause, bounded static/test overrides, immediate final-step stop, and exact canonical-controller identity. Its adversarial tests mutate the canonical template to prove each failure is rejected.
+The verifier checks mode/state declarations, contiguous steps, motion budgets, complete SVG naming, no-JS source visibility, decorative accessibility, the full control set, live status, reduced-motion/print CSS, keyboard handling, page-hide pause, bounded static/test overrides, immediate final-step stop, and exact canonical-controller identity. Root SVG icons marked `aria-hidden="true"` are exempt from diagram naming checks, while the document still needs an accessible SVG (exactly one for the policy-trace example). Its adversarial tests mutate the canonical template to prove each failure is rejected.
Then verify in a browser: