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(heatmap): read a quoted greater-than in markup (#470)

Rudy Mizrahi Celeklid3add5fef2b4
diff --git a/scripts/test-verify-heatmap.py b/scripts/test-verify-heatmap.py
index 9c5b3fd..4eba5b0 100644
--- a/scripts/test-verify-heatmap.py
+++ b/scripts/test-verify-heatmap.py
@@ -107,7 +107,7 @@ def case(
expect_pass: bool,
describe: str,
) -> None:
- if source == original and not expect_pass:
+ if source == original:
failures.append(
f"could not build the {name!r} fixture (anchor not found in source)"
)
@@ -159,6 +159,27 @@ def main() -> int:
)
case(failures, d, "P-mixed-single-quotes.html", mixed_single, single_quoted, True,
"double-quoted text inside metadata does not override a single-quoted fill")
+ quoted_gt = original.replace(
+ "<rect " + FIRST_NONFOCAL,
+ '<rect data-note="p95>budget" ' + FIRST_NONFOCAL,
+ 1,
+ )
+ case(failures, d, "P-quoted-greater-than.html", quoted_gt, original, True,
+ "a greater-than inside a double-quoted attribute does not drop the cell")
+ single_gt = original.replace(
+ "<rect " + FIRST_NONFOCAL,
+ "<rect data-note='p95>budget' " + FIRST_NONFOCAL,
+ 1,
+ )
+ case(failures, d, "P-single-quoted-greater-than.html", single_gt, original, True,
+ "a greater-than inside a single-quoted attribute does not drop the cell")
+ label_gt = original.replace(
+ '<text data-row-label="auth"',
+ '<text data-note="a>b" data-row-label="auth"',
+ 1,
+ )
+ case(failures, d, "P-quoted-greater-than-axis.html", label_gt, original, True,
+ "a greater-than inside axis metadata does not drop the row label")
commented_transform = original.replace('</style>', '/* archived experiment\n transform: translateX(12px);\n */\n</style>', 1)
case(failures, d, "P-commented-transform.html", commented_transform, original, True,
diff --git a/scripts/verify-heatmap.py b/scripts/verify-heatmap.py
index c7f16ae..4265f6e 100644
--- a/scripts/verify-heatmap.py
+++ b/scripts/verify-heatmap.py
@@ -58,8 +58,11 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
ASSET_DIR = ROOT / "skills/diagram-design/assets"
-RECT_RE = re.compile(r"<rect\b(?P<attrs>[^>]*?)/?>", re.IGNORECASE)
-TEXT_RE = re.compile(r"<text\b(?P<attrs>[^>]*)>", re.IGNORECASE)
+# A ">" inside a quoted attribute is text, not the end of the tag. Ending the
+# scan there drops the cell or axis label that follows it.
+_ATTRS = r"""(?:"[^"]*"|'[^']*'|[^"'<>])*"""
+RECT_RE = re.compile(rf"<rect\b(?P<attrs>{_ATTRS})/?>", re.IGNORECASE)
+TEXT_RE = re.compile(rf"<text\b(?P<attrs>{_ATTRS})>", re.IGNORECASE)
COMMENT_RE = re.compile(r"<!--.*?-->", re.DOTALL)
STYLE_RE = re.compile(r"<style\b[^>]*>(?P<body>.*?)</style>", re.IGNORECASE | re.DOTALL)
COMMENT_OR_STYLE_RE = re.compile(