sysprom 1.23.0 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,6 +105,24 @@ const NODE_TYPE_SHAPES = {
105
105
  export function mermaidShapeForNode(node) {
106
106
  return NODE_TYPE_SHAPES[node.type] ?? "rectangle";
107
107
  }
108
+ /**
109
+ * Escape a Mermaid label by wrapping in quotes if it contains special characters.
110
+ * Mermaid shape delimiters and other special chars need escaping: ( ) { } [ ] / \
111
+ * Wrapping in double quotes allows these characters to be rendered as-is.
112
+ * @param label - The label text to escape
113
+ * @returns The label, quoted if it contains special characters
114
+ * @example
115
+ * escapeMermaidLabel("Firebase (Tenant)") // returns '"Firebase (Tenant)"'
116
+ */
117
+ function escapeMermaidLabel(label) {
118
+ // Check if label contains any Mermaid special characters that need escaping
119
+ const specialChars = ["(", ")", "{", "}", "[", "]", "/", "\\"];
120
+ if (specialChars.some((char) => label.includes(char))) {
121
+ // Wrap in double quotes to escape
122
+ return `"${label}"`;
123
+ }
124
+ return label;
125
+ }
108
126
  /**
109
127
  * Render a Mermaid node definition for a node id/name/shape.
110
128
  * @param id - Node id
@@ -116,16 +134,17 @@ export function mermaidShapeForNode(node) {
116
134
  export function renderMermaidNode(id, name, shape, mode = "friendly") {
117
135
  const safeId = sanitiseMermaidId(id);
118
136
  const label = mode === "compact" ? id : `${id}: ${name}`;
137
+ const escapedLabel = escapeMermaidLabel(label);
119
138
  switch (shape) {
120
139
  case "rounded":
121
- return `${safeId}([${label}])`;
140
+ return `${safeId}([${escapedLabel}])`;
122
141
  case "rhombus":
123
- return `${safeId}{{${label}}}`;
142
+ return `${safeId}{{${escapedLabel}}}`;
124
143
  case "parallelogram":
125
- return `${safeId}[/${label}/]`;
144
+ return `${safeId}[/${escapedLabel}/]`;
126
145
  case "rectangle":
127
146
  default:
128
- return `${safeId}[${label}]`;
147
+ return `${safeId}[${escapedLabel}]`;
129
148
  }
130
149
  }
131
150
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sysprom",
3
- "version": "1.23.0",
3
+ "version": "1.23.1",
4
4
  "description": "SysProM — System Provenance Model CLI and library",
5
5
  "author": "ExaDev",
6
6
  "homepage": "https://exadev.github.io/SysProM",