MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / data_to_markdown

Method data_to_markdown

src/data/flow_format.py:16–43  ·  view source on GitHub ↗

Convert graph data to .md markdown format.

(self, graph_data: Dict[str, Any], title: str = "Untitled Graph", 
                    description: str = "")

Source from the content-addressed store, hash-verified

14 self.md = MarkdownIt()
15
16 def data_to_markdown(self, graph_data: Dict[str, Any], title: str = "Untitled Graph",
17 description: str = "") -> str:
18 """Convert graph data to .md markdown format."""
19
20 flow_content = f"# {title}\n\n"
21 if description:
22 flow_content += f"{description}\n\n"
23
24 # Add nodes
25 for node in graph_data.get("nodes", []):
26 flow_content += self._node_to_flow(node)
27 flow_content += "\n"
28
29 # Add groups (if any)
30 groups = graph_data.get("groups", [])
31 if groups:
32 flow_content += "## Groups\n\n"
33 flow_content += "```json\n"
34 flow_content += json.dumps(groups, indent=2)
35 flow_content += "\n```\n\n"
36
37 # Add connections
38 flow_content += "## Connections\n\n"
39 flow_content += "```json\n"
40 flow_content += json.dumps(graph_data.get("connections", []), indent=2)
41 flow_content += "\n```\n"
42
43 return flow_content
44
45 def _node_to_flow(self, node: Dict[str, Any]) -> str:
46 """Convert a single node to .md format."""

Callers 4

copy_selectedMethod · 0.95
save_flow_fileFunction · 0.95
_save_fileMethod · 0.95

Calls 1

_node_to_flowMethod · 0.95

Tested by 1