Skip to content

Commit 119daa3

Browse files
Anthony Juckelajuckel
Anthony Juckel
authored andcommitted
Apply non-markdown label change for subgroups
1 parent dd9901a commit 119daa3

File tree

3 files changed

+40
-6
lines changed

3 files changed

+40
-6
lines changed

cypress/integration/rendering/flowchart.spec.js

+28-1
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ graph TD
936936
);
937937
});
938938

939-
it('#5824: should be able to string and markdown labels', () => {
939+
it('#5824: should be able to use string and markdown labels', () => {
940940
imgSnapshotTest(
941941
`
942942
flowchart TB
@@ -956,4 +956,31 @@ flowchart TB
956956
}
957957
);
958958
});
959+
960+
it('#5824: should render subgraphs with adhoc list headings', () => {
961+
imgSnapshotTest(
962+
`
963+
graph TB
964+
subgraph "1. first"
965+
a1-->a2
966+
end
967+
subgraph 2. second
968+
b1-->b2
969+
end
970+
`,
971+
{ fontFamily: 'courier' }
972+
);
973+
});
974+
975+
it('#5824: should render subgraphs with markdown headings', () => {
976+
imgSnapshotTest(
977+
`
978+
graph TB
979+
subgraph "\`**strong**\`"
980+
a1-->a2
981+
end
982+
`,
983+
{ fontFamily: 'courier' }
984+
);
985+
});
959986
});

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)