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(service-blueprint): accept Japanese two-line printed labels (#439)

maxiaochaosc2b1f7aeb613
diff --git a/scripts/fixtures/service-blueprint-japanese-two-line.html b/scripts/fixtures/service-blueprint-japanese-two-line.html
new file mode 100644
index 0000000..f579fec
--- /dev/null
+++ b/scripts/fixtures/service-blueprint-japanese-two-line.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html lang="ja">
+<head><meta charset="utf-8"/><title>service-blueprint japanese two-line labels (#438)</title>
+<style>
+ :root { --color-paper: #ffffff; --color-accent: #e4572e; }
+ body { margin: 0; background: var(--color-paper); }
+</style>
+</head>
+<body>
+<svg xmlns="http://www.w3.org/2000/svg" width="560" height="420" viewBox="0 0 560 420">
+ <rect x="40" y="24" width="200" height="24" fill="#ffffff" data-stage="sign-up"/>
+ <text x="140" y="40" fill="#2d3142" font-size="12" text-anchor="middle">sign-up</text>
+ <rect x="260" y="24" width="200" height="24" fill="#ffffff" data-stage="use"/>
+ <text x="360" y="40" fill="#2d3142" font-size="12" text-anchor="middle">use</text>
+
+ <g data-layer="customer">
+ <!-- Japanese split across two <text> lines -->
+ <rect x="40" y="80" width="200" height="48" rx="4" fill="#ffffff" stroke="#2d3142" stroke-width="1"
+ data-stage="sign-up" data-name="歓迎メール"/>
+ <text x="140" y="98" fill="#2d3142" font-size="12" text-anchor="middle">歓迎</text>
+ <text x="140" y="114" fill="#2d3142" font-size="12" text-anchor="middle">メール</text>
+ <!-- Japanese split across two <tspan>s inside one <text> -->
+ <rect x="260" y="80" width="200" height="48" rx="4" fill="#ffffff" stroke="#2d3142" stroke-width="1"
+ data-stage="use" data-name="注文確認"/>
+ <text x="360" y="108" fill="#2d3142" font-size="12" text-anchor="middle">
+ <tspan x="360" dy="0">注文</tspan>
+ <tspan x="360" dy="16">確認</tspan>
+ </text>
+ </g>
+
+ <g data-layer="frontstage">
+ <!-- English two-line still joins with a space -->
+ <rect x="40" y="160" width="200" height="64" rx="4" fill="#ffffff" stroke="#2d3142" stroke-width="1"
+ data-stage="sign-up" data-name="Welcome email"/>
+ <text x="140" y="184" fill="#2d3142" font-size="12" text-anchor="middle">Welcome</text>
+ <text x="140" y="200" fill="#2d3142" font-size="12" text-anchor="middle">email</text>
+ <rect x="260" y="160" width="200" height="64" rx="4" fill="#ffffff" stroke="#2d3142" stroke-width="1"
+ data-stage="use" data-name="Track order"/>
+ <text x="360" y="196" fill="#2d3142" font-size="12" text-anchor="middle">Track order</text>
+ </g>
+
+ <line x1="40" y1="250" x2="460" y2="250" stroke="rgba(45,49,66,0.55)" stroke-width="2" data-role="visibility"/>
+
+ <g data-layer="backstage">
+ <rect x="40" y="280" width="200" height="48" rx="4" fill="#ffffff" stroke="#2d3142" stroke-width="1"
+ data-stage="sign-up" data-name="Create account"/>
+ <text x="140" y="308" fill="#2d3142" font-size="12" text-anchor="middle">Create account</text>
+ <rect x="260" y="280" width="200" height="48" rx="4" fill="#ffffff" stroke="#2d3142" stroke-width="1"
+ data-stage="use" data-name="Fulfillment"/>
+ <text x="360" y="308" fill="#2d3142" font-size="12" text-anchor="middle">Fulfillment</text>
+ </g>
+</svg>
+</body>
+</html>
diff --git a/scripts/test-verify-service-blueprint.py b/scripts/test-verify-service-blueprint.py
index 4ef09d4..05e37fd 100644
--- a/scripts/test-verify-service-blueprint.py
+++ b/scripts/test-verify-service-blueprint.py
@@ -300,6 +300,130 @@ def main() -> int:
else:
print("OK: overlapping columns fail by name")
+ # Japanese labels omit spaces: two <text> lines for one data-name must
+ # pass (issue #438). Scope the no-whitespace join to one cell only.
+ welcome_rect = (
+ '<rect x="96" y="80" width="208" height="48" rx="4" fill="#ffffff" '
+ 'stroke="#2d3142" stroke-width="1" data-stage="sign-up" '
+ 'data-name="Welcome email"/>'
+ )
+ welcome_text = (
+ '<text x="200" y="108" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">Welcome email</text>'
+ )
+ if welcome_rect not in source or welcome_text not in source:
+ failures.append("could not build Japanese two-line printed fixtures (anchor missing)")
+ else:
+ ja_rect = welcome_rect.replace('data-name="Welcome email"', 'data-name="歓迎メール"')
+ ja_two_text = (
+ '<text x="200" y="100" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">歓迎</text>\n'
+ ' <text x="200" y="116" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">メール</text>'
+ )
+ ja_src = source.replace(welcome_rect, ja_rect, 1).replace(welcome_text, ja_two_text, 1)
+ code, output = run(str(write(directory, "japanese-two-text-lines.html", ja_src)))
+ if code != 0:
+ failures.append(f"Japanese two <text> lines should pass:\n{output}")
+ else:
+ print("OK: Japanese two <text> lines pass")
+
+ ja_tspan = (
+ '<text x="200" y="100" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">\n'
+ ' <tspan x="200" dy="0">歓迎</tspan>\n'
+ ' <tspan x="200" dy="16">メール</tspan>\n'
+ ' </text>'
+ )
+ ja_tspan_src = source.replace(welcome_rect, ja_rect, 1).replace(
+ welcome_text, ja_tspan, 1
+ )
+ code, output = run(str(write(directory, "japanese-two-tspan.html", ja_tspan_src)))
+ if code != 0:
+ failures.append(f"Japanese two <tspan> lines should pass:\n{output}")
+ else:
+ print("OK: Japanese two <tspan> lines pass")
+
+ en_two = (
+ '<text x="200" y="100" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">Welcome</text>\n'
+ ' <text x="200" y="116" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">email</text>'
+ )
+ en_src = source.replace(welcome_text, en_two, 1)
+ code, output = run(str(write(directory, "english-two-text-lines.html", en_src)))
+ if code != 0:
+ failures.append(f"English two <text> lines should still pass:\n{output}")
+ else:
+ print("OK: English two <text> lines still pass")
+
+ # Neighbouring cell text must not satisfy another cell's data-name
+ # if we only strip whitespace globally across the plot.
+ neighbor_fail = source.replace(
+ welcome_rect,
+ welcome_rect.replace('data-name="Welcome email"', 'data-name="歓迎メール"'),
+ 1,
+ ).replace(welcome_text, welcome_text.replace("Welcome email", "歓迎"), 1)
+ # Leave the rest of the diagram intact; compact join is cell-scoped,
+ # so "歓迎" alone must not match "歓迎メール".
+ code, output = run(str(write(directory, "japanese-partial-label.html", neighbor_fail)))
+ if code == 0 or "printed: cell '歓迎メール'" not in output:
+ failures.append(
+ f"partial Japanese label should fail printed check, got:\n{output}"
+ )
+ else:
+ print("OK: partial Japanese label fails printed check")
+
+ # Greptile gap: the split must NOT stitch across cells. The target
+ # cell (Welcome email, x=96) prints only 歓迎, and the next cell
+ # (Product UI, x=320) prints メール. The cell-scoped join collects
+ # each cell's text by its own x/y, so メール in the Product UI cell
+ # never reaches the Welcome email cell — the printed check must
+ # still report 歓迎メール as missing. Pin this so a regression to a
+ # global whitespace strip is caught.
+ product_ui_text = (
+ '<text x="424" y="108" fill="#2d3142" font-size="12" '
+ 'font-family="\'Geist\', sans-serif" text-anchor="middle">Product UI</text>'
+ )
+ if product_ui_text not in source:
+ failures.append(
+ "could not build the cross-cell split fixture (Product UI anchor missing)"
+ )
+ else:
+ cross_cell = (
+ source.replace(
+ welcome_rect,
+ welcome_rect.replace(
+ 'data-name="Welcome email"', 'data-name="歓迎メール"'
+ ),
+ 1,
+ )
+ .replace(welcome_text, welcome_text.replace("Welcome email", "歓迎"), 1)
+ .replace(product_ui_text, product_ui_text.replace("Product UI", "メール"), 1)
+ )
+ code, output = run(
+ str(write(directory, "japanese-cross-cell-split.html", cross_cell))
+ )
+ if code == 0 or "printed: cell '歓迎メール'" not in output:
+ failures.append(
+ f"cross-cell split should fail printed check (cell-scoped join must "
+ f"not stitch 歓迎 + メール across cells), got:\n{output}"
+ )
+ else:
+ print("OK: cross-cell split fails printed check (cell-scoped join holds)")
+
+ # Fixture under scripts/fixtures covers the same Japanese / tspan cases
+ # on a minimal blueprint (see #438).
+ fixture = ROOT / "scripts/fixtures/service-blueprint-japanese-two-line.html"
+ if not fixture.is_file():
+ failures.append(f"missing fixture {fixture}")
+ else:
+ code, output = run(str(fixture))
+ if code != 0:
+ failures.append(f"japanese two-line fixture should pass:\n{output}")
+ else:
+ print("OK: scripts/fixtures/service-blueprint-japanese-two-line.html passes")
+
# Single-quoted attributes are valid SVG; a cell written that way
# must still be checked. Evidence cells are not in the census, so a
# skipped one could sit below the line without any finding.
diff --git a/scripts/verify-service-blueprint.py b/scripts/verify-service-blueprint.py
index a41b59e..a8b5bb4 100644
--- a/scripts/verify-service-blueprint.py
+++ b/scripts/verify-service-blueprint.py
@@ -891,7 +891,12 @@ def check_printed(source: str, cells: list[Cell], errors: list[str]) -> None:
and cell.y - 1 <= y <= cell.bottom + 6
]
haystack = " ".join(collected)
- if cell.name not in haystack:
+ # Japanese (and similar) labels omit spaces between words. Two <text>
+ # lines or whitespace-split <tspan>s inside one cell must still match
+ # data-name when that cell's own collected parts are concatenated with
+ # whitespace removed. Do not strip whitespace across neighbouring cells.
+ compact = "".join(re.sub(r"\s+", "", part) for part in collected)
+ if cell.name not in haystack and cell.name not in compact:
errors.append(
f"printed: cell {cell.name!r} has no visible text containing its "
"data-name"