diff --git a/dvc/commands/dag.py b/dvc/commands/dag.py index bbf4ac2fa..5797f49bc 100644 --- a/dvc/commands/dag.py +++ b/dvc/commands/dag.py @@ -42,7 +42,7 @@ def _show_mermaid(G, markdown: bool = False): for node in nodes: total_nodes += 1 node_id = f"node{total_nodes}" - graph += f"\n\t{node_id}[{node}]" + graph += f'\n\t{node_id}["{node}"]' node_ids[node] = node_id edges = sorted((str(a), str(b)) for b, a in pipeline.edges) for a, b in edges: diff --git a/tests/unit/command/test_dag.py b/tests/unit/command/test_dag.py index 3e3a8daca..3d115005c 100644 --- a/tests/unit/command/test_dag.py +++ b/tests/unit/command/test_dag.py @@ -165,12 +165,12 @@ def test_show_mermaid(repo): line.rstrip() for line in _show_mermaid(repo.index.graph).splitlines() ] == [ "flowchart TD", - "\tnode1[stage: '1']", - "\tnode2[stage: '2']", - "\tnode3[stage: '3']", - "\tnode4[stage: '4']", - "\tnode5[stage: 'a.dvc']", - "\tnode6[stage: 'b.dvc']", + "\tnode1[\"stage: '1'\"]", + "\tnode2[\"stage: '2'\"]", + "\tnode3[\"stage: '3'\"]", + "\tnode4[\"stage: '4'\"]", + "\tnode5[\"stage: 'a.dvc'\"]", + "\tnode6[\"stage: 'b.dvc'\"]", "\tnode3-->node4", "\tnode5-->node1", "\tnode5-->node3", @@ -190,12 +190,12 @@ def test_show_mermaid_markdown(repo, dvc, capsys, mocker): ] == [ "```mermaid", "flowchart TD", - "\tnode1[stage: '1']", - "\tnode2[stage: '2']", - "\tnode3[stage: '3']", - "\tnode4[stage: '4']", - "\tnode5[stage: 'a.dvc']", - "\tnode6[stage: 'b.dvc']", + "\tnode1[\"stage: '1'\"]", + "\tnode2[\"stage: '2'\"]", + "\tnode3[\"stage: '3'\"]", + "\tnode4[\"stage: '4'\"]", + "\tnode5[\"stage: 'a.dvc'\"]", + "\tnode6[\"stage: 'b.dvc'\"]", "\tnode3-->node4", "\tnode5-->node1", "\tnode5-->node3",