Skip to content

Commit af6cf0e

Browse files
author
Anthony Juckel
committed
Apply non-markdown label change for subgroups
1 parent a538b7f commit af6cf0e

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

cypress/integration/rendering/flowchart.spec.js

+25
Original file line numberDiff line numberDiff line change
@@ -937,4 +937,29 @@ flowchart TB
937937
}
938938
);
939939
});
940+
it('69: should render subgraphs with adhoc list headings', () => {
941+
imgSnapshotTest(
942+
`
943+
graph TB
944+
subgraph "1. first"
945+
a1-->a2
946+
end
947+
subgraph 2. second
948+
b1-->b2
949+
end
950+
`,
951+
{ fontFamily: 'courier' }
952+
);
953+
});
954+
it('70: should render subgraphs with markdown headings', () => {
955+
imgSnapshotTest(
956+
`
957+
graph TB
958+
subgraph "\`**strong**\`"
959+
a1-->a2
960+
end
961+
`,
962+
{ fontFamily: 'courier' }
963+
);
964+
});
940965
});

packages/mermaid/src/diagrams/flowchart/flowDb.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ You have to call mermaid.initialize.`
10851085
id: subGraph.id,
10861086
label: subGraph.title,
10871087
labelStyle: '',
1088+
labelType: subGraph.labelType,
10881089
parentId: parentDB.get(subGraph.id),
10891090
padding: 8,
10901091
cssCompiledStyles: this.getCompiledStyles(subGraph.classes),

packages/mermaid/src/rendering-util/rendering-elements/clusters.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ const rect = async (parent, node) => {
3030
// Create the label and insert it after the rect
3131
const labelEl = shapeSvg.insert('g').attr('class', 'cluster-label ');
3232

33-
const text = await createText(labelEl, node.label, {
34-
style: node.labelStyle,
35-
useHtmlLabels,
36-
isNode: true,
37-
});
33+
let text;
34+
if (node.labelType === 'markdown') {
35+
text = await createText(labelEl, node.label, {
36+
style: node.labelStyle,
37+
useHtmlLabels,
38+
isNode: true,
39+
});
40+
} else {
41+
const labelElement = await createLabel(node.label, node.labelStyle, false, true);
42+
text = labelEl.node()?.appendChild(labelElement);
43+
}
3844

3945
// Get the size of the label
4046
let bbox = text.getBBox();

0 commit comments

Comments
 (0)