MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / parse_workflows

Function parse_workflows

backend/mermaid_parser.py:207–239  ·  view source on GitHub ↗

Split diagram into separate workflow blocks. Returns list of (workflow_name, lines) tuples.

(diagram: str)

Source from the content-addressed store, hash-verified

205
206
207def parse_workflows(diagram: str) -> List[Tuple[str, List[str]]]:
208 """Split diagram into separate workflow blocks.
209
210 Returns list of (workflow_name, lines) tuples.
211 """
212 workflows = []
213 current_name = "Main Workflow"
214 current_lines = []
215
216 for line in diagram.strip().split("\n"):
217 line = line.strip()
218
219 # New flowchart block
220 if line.startswith("flowchart"):
221 if current_lines:
222 workflows.append((current_name, current_lines))
223 current_lines = []
224 current_name = "Main Workflow"
225 continue
226
227 # Workflow name comment
228 if line.startswith("%% Workflow:"):
229 current_name = line.replace("%% Workflow:", "").strip()
230 continue
231
232 if line and not line.startswith("%%"):
233 current_lines.append(line)
234
235 # Don't forget last workflow
236 if current_lines:
237 workflows.append((current_name, current_lines))
238
239 return workflows
240
241
242def parse_flowchart(lines: List[str], metadata: Dict[str, Any]) -> Tuple[List[GraphNode], List[GraphEdge]]:

Callers 1

parse_mermaid_responseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected