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(geometry): read single-quoted SVG attributes (#484)

YalcinkayaEd39a365cc974
diff --git a/scripts/test-verify-geometry.py b/scripts/test-verify-geometry.py
index 635b1b4..e26b026 100644
--- a/scripts/test-verify-geometry.py
+++ b/scripts/test-verify-geometry.py
@@ -87,6 +87,18 @@ def main() -> int:
document('<rect x="240" y="80" width="48" height="12" rx="2" fill="#f5f5f5"/>' + node),
1,
)
+ check(
+ "single-quoted mask clipped by a single-quoted node",
+ document("<rect x='240' y='80' width='48' height='12' fill='#f5f5f5'/>"
+ "<rect x='100' y='60' width='160' height='64' fill='#eee'/>"),
+ 1,
+ )
+ check(
+ "attribute-like text inside a value does not replace real coordinates",
+ document("<rect data-note=\"x='10' y='10'\" x='240' y='80' width='48' height='12' fill='#fff'/>"
+ + node),
+ 1,
+ )
# Same geometry, but the node is painted first, so the label stays on top.
check(
"mask over an earlier node is legal",
@@ -123,6 +135,8 @@ def main() -> int:
translated_mask = '<rect x="350" y="80" width="80" height="12" fill="#fff"/>'
check("translated mask is clipped in canvas space", document(
'<g transform="translate(-200 0)">' + translated_mask + '</g>' + panel_node), 1)
+ check("single-quoted group translation is applied", document(
+ "<g transform='translate(-200 0)'>" + translated_mask + '</g>' + panel_node), 1)
check("nested translations accumulate", document(
'<g transform="translate(-100 0)"><g transform="translate(-100 0)">'
+ translated_mask + '</g></g>' + panel_node), 1)
@@ -213,6 +227,33 @@ def main() -> int:
document(f'<line x1="10" y1="10" x2="60" y2="40" {arrow}/>'),
1,
)
+ check(
+ "single-quoted diagonal connector",
+ document("<line x1='10' y1='10' x2='60' y2='40' "
+ "stroke='#4f5d75' marker-end='url(#arrow)'/>"),
+ 1,
+ )
+ check(
+ "diagonal connector with adjacent attributes",
+ document(f'<line x1="10" y1="10"x2="60" y2="40" {arrow}/>'),
+ 1,
+ )
+ check(
+ "diagonal connector with slash between attributes",
+ document(f'<line x1="10" y1="10"/x2="60" y2="40" {arrow}/>'),
+ 1,
+ )
+ check(
+ "attribute-like coordinates inside an unusual name are ignored",
+ document(f'<line @click=" x1=\'10\' y1=\'10\' x2=\'60\' y2=\'10\'" '
+ f'x1="10" y1="10" x2="60" y2="40" {arrow}/>'),
+ 1,
+ )
+ check(
+ "single-quoted arrowed path",
+ document("<path d='M 10 10 L 60 40' stroke='#4f5d75' marker-end='url(#arrow)'/>"),
+ 1,
+ )
check(
"diagonal line without a marker is not a connector",
document('<line x1="10" y1="10" x2="60" y2="40" stroke="#4f5d75"/>'),
diff --git a/scripts/verify-geometry.py b/scripts/verify-geometry.py
index 20e6550..de7de99 100644
--- a/scripts/verify-geometry.py
+++ b/scripts/verify-geometry.py
@@ -126,6 +126,7 @@ TAG_RE = re.compile(
r"<!--[\s\S]*?-->|<(?P<close>/?)(?P<tag>g|svg|defs|symbol|marker|pattern|clipPath|mask|rect|path|line)\b(?P<attrs>(?:\"[^\"]*\"|'[^']*'|[^'\">])*?)(?P<empty>/?)>",
re.IGNORECASE,
)
+ATTR_RE = re.compile(r'''([^\s"'>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|[^\s>]*))?''')
TRANSLATE_RE = re.compile(
r"^\s*translate\(\s*([-+]?[\d.]+)(?:[\s,]+([-+]?[\d.]+))?\s*\)\s*$"
)
@@ -148,8 +149,10 @@ SMALL_EDGE = 48.0 # ...meaning an edge shorter than this
def attribute(attrs: str, name: str) -> str | None:
- match = re.search(rf'(?<![\w-]){re.escape(name)}\s*=\s*"([^"]*)"', attrs)
- return match.group(1) if match else None
+ for match in ATTR_RE.finditer(attrs):
+ if match.group(1) == name:
+ return match.group(2) if match.group(2) is not None else match.group(3)
+ return None
def number(attrs: str, name: str) -> float | None:
diff --git a/skills/diagram-design/references/primitives-core.md b/skills/diagram-design/references/primitives-core.md
index fdfd638..28af410 100644
--- a/skills/diagram-design/references/primitives-core.md
+++ b/skills/diagram-design/references/primitives-core.md
@@ -51,7 +51,7 @@ Don't use the dot pattern when the diagram sits inside a product page, slide, or
**Draw arrows before boxes** so z-order puts lines behind nodes.
-The geometry source gate excludes shapes inside definition-only containers (`defs`, `symbol`, `marker`, `pattern`, `clipPath`, `mask`) because those shapes do not paint at their local coordinates. It does not resolve `<use>` instances; check referenced drawings with rendered lint and visual review. Inert HTML comments and `>` inside quoted tag attributes do not alter definition custody.
+The geometry source gate excludes shapes inside definition-only containers (`defs`, `symbol`, `marker`, `pattern`, `clipPath`, `mask`) because those shapes do not paint at their local coordinates. It does not resolve `<use>` instances; check referenced drawings with rendered lint and visual review. Inert HTML comments and `>` inside quoted tag attributes do not alter definition custody. The gate reads single- and double-quoted SVG attributes.
## Mandatory connector rules