arrows.app
arrows.app copied to clipboard
Import/export Mermaid
Given that markdown supports Mermaid, importing and exporting to this format would be great for documentation.
Hi @mattorp !
We're pretty interested in defining a clear extension point for import/export formats. Mermaid makes sense as a candidate format once that is in place.
Exporting should be straightforward. Importing may be less useful until we have another extension point defined, for alignment and layout. Mermaid assumes autolayout. Arrows assumes user defined layout. We can reconcile this on the Arrows side by supporting the classic drawing-program behavior of selecting some elements, then applying one of various layout/aligment strategies.
Cheers, ABK
Hi @akollegger, awesome!
For anyone interested, here's a quick and dirty python script to produce mermaid output from the Arrows JSON export.
import json
def generate_mermaid_diagram(arrows_app_output):
diagram = "graph TD;\n"
for node in arrows_app_output["nodes"]:
node_id = node["id"]
caption = node.get("caption", "")
labels = ",".join(node["labels"])
diagram += f' {node_id}["{caption}\\n({labels})"];\n'
for relationship in arrows_app_output["relationships"]:
from_id = relationship["fromId"]
to_id = relationship["toId"]
relationship_type = relationship.get("type", "")
diagram += f' {from_id} -->'
if relationship_type:
diagram += f'|{relationship_type}|'
diagram += f'{to_id};\n'
return diagram
# Load Arrows.app output from JSON
arrows_app_output_json = '''
PASTE YOUR ARROWS APP JSON HERE
'''
arrows_app_output = json.loads(arrows_app_output_json)
# Generate Mermaid diagram
mermaid_diagram = generate_mermaid_diagram(arrows_app_output)
print(mermaid_diagram)