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(import): accept whitespace before a Mermaid pipe label (#446)
Rudy Mizrahi Celekli64203b74bd45
diff --git a/scripts/verify-mermaid-import.py b/scripts/verify-mermaid-import.pyindex 5232cb2..c136881 100644--- a/scripts/verify-mermaid-import.py+++ b/scripts/verify-mermaid-import.py@@ -1274,6 +1274,20 @@ def check_node_shape_updates(tmp: Path) -> None:ok("node declarations update shapes while bare references preserve them")+def check_spaced_pipe_labels(tmp: Path) -> None:+ flow = tmp / "spaced-pipe-labels.mmd"+ flow.write_text(+ "flowchart TD\nA --> |solid| B\nB -.-> |dotted| C\nC ==> |thick| D\nD --- |plain| E\nE -->|tight| F\n",+ encoding="utf-8",+ )+ diagram = json.loads(run_extract([str(flow), "--json"]))["diagrams"][0]+ edges = [(edge["source"], edge["target"], edge["label"]) for edge in diagram["edges"]]+ expected = [("A", "B", "solid"), ("B", "C", "dotted"), ("C", "D", "thick"), ("D", "E", "plain"), ("E", "F", "tight")]+ if edges != expected:+ fail(f"a pipe label after whitespace must stay a label: {edges!r}")+ ok("pipe labels may follow whitespace after the link operator")++def check_unicode_state_regression(tmp: Path) -> None:path = tmp / "unicode-state.mmd"path.write_text('stateDiagram-v2\n待机 : 等待输入\n待机 --> 完成\n', encoding="utf-8")@@ -1400,6 +1414,7 @@ def main() -> int:check_flowchart()check_bidirectional_analysis(tmp)check_node_shape_updates(tmp)+ check_spaced_pipe_labels(tmp)check_entity_label_codes(tmp)check_shape_and_edge_vocabulary(tmp)check_frontmatter(tmp)diff --git a/skills/diagram-design/scripts/mermaid_extract.py b/skills/diagram-design/scripts/mermaid_extract.pyindex 5987ed3..ee9592d 100644--- a/skills/diagram-design/scripts/mermaid_extract.py+++ b/skills/diagram-design/scripts/mermaid_extract.py@@ -737,10 +737,15 @@ def _edge_operators(text: str) -> list[_Operator]:token = match.group()end = match.end()label = ""- if end < len(text) and text[end] == "|":- close = text.find("|", end + 1)+ # Mermaid allows whitespace between the link and its pipe label:+ # `A --> |yes| B` reads the same as `A -->|yes| B`.+ opening_pipe = end+ while opening_pipe < len(text) and text[opening_pipe] in " \t":+ opening_pipe += 1+ if opening_pipe < len(text) and text[opening_pipe] == "|":+ close = text.find("|", opening_pipe + 1)if close != -1:- label = clean_label(text[end + 1 : close])+ label = clean_label(text[opening_pipe + 1 : close])end = close + 1style, arrowhead, bidirectional, undirected = _operator_style(token)operators.append(