feat(arch): extended parser to control how edges pass through groups

This commit is contained in:
NicolasNewman
2024-05-09 14:33:44 -05:00
parent 48e6901936
commit 5b6c95cea3
6 changed files with 211 additions and 143 deletions

View File

@@ -1,23 +1,24 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Architecture Mermaid Quick Test Page</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
<style>
div.mermaid {
/* font-family: 'trebuchet ms', verdana, arial; */
font-family: 'Courier New', Courier, monospace !important;
}
</style>
</head>
<body>
<h1>Architecture diagram demo</h1>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Architecture Mermaid Quick Test Page</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
<style>
div.mermaid {
/* font-family: 'trebuchet ms', verdana, arial; */
font-family: 'Courier New', Courier, monospace !important;
}
</style>
</head>
<h2>Simple diagram with groups</h2>
<pre class="mermaid">
<body>
<h1>Architecture diagram demo</h1>
<h2>Simple diagram with groups</h2>
<pre class="mermaid">
architecture
group api(cloud)[API]
@@ -32,10 +33,10 @@
disk2 T--B db
server T--B gateway
</pre>
<hr />
<hr />
<h2>Groups within groups</h2>
<pre class="mermaid">
<h2>Groups within groups</h2>
<pre class="mermaid">
architecture
group api[API]
group public[Public API] in api
@@ -56,17 +57,17 @@
serv1 L--R gateway
</pre>
<hr />
<hr />
<h2>Default icon (?) from uknown icon name</h2>
<pre class="mermaid">
<h2>Default icon (?) from uknown icon name</h2>
<pre class="mermaid">
architecture
service unknown(iconnamedoesntexist)[Uknown Icon]
</pre>
<hr />
<hr />
<h2>Split Direction</h2>
<pre class="mermaid">
<h2>Split Direction</h2>
<pre class="mermaid">
architecture
service db(database)[Database]
service s3(disk)[Storage]
@@ -79,10 +80,10 @@
serv2 L--B s3
serv1 T--B disk
</pre>
<hr />
<hr />
<h2>Arrow Tests</h2>
<pre class="mermaid">
<h2>Arrow Tests</h2>
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
@@ -100,7 +101,7 @@
servR (T--R) servT
servR (B--R) servB
</pre>
<pre class="mermaid">
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
@@ -118,10 +119,32 @@
servT (R--T) servR
servB (R--B) servR
</pre>
<hr />
<hr />
<h2>Edge Label Test</h2>
<pre class="mermaid">
<h2>Group Edges</h2>
<pre class="mermaid">
architecture
group left_group(cloud)[Left]
group right_group(cloud)[Right]
group top_group(cloud)[Top]
group bottom_group(cloud)[Bottom]
group center_group(cloud)[Center]
service left_disk(disk)[Disk] in left_group
service right_disk(disk)[Disk] in right_group
service top_disk(disk)[Disk] in top_group
service bottom_disk(disk)[Disk] in bottom_group
service center_disk(disk)[Disk] in center_group
left_disk{group} (R--L) center_disk{group}
right_disk{group} (L--R) center_disk{group}
top_disk{group} (B--T) center_disk{group}
bottom_disk{group} (T--B) center_disk{group}
</pre>
<hr />
<h2>Edge Label Test</h2>
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
@@ -139,7 +162,7 @@
servR T-[Label]-R servT
servR B-[Label]-R servB
</pre>
<pre class="mermaid">
<pre class="mermaid">
architecture
service servC(server)[Server 1]
service servL(server)[Server 2]
@@ -158,74 +181,75 @@
servR B-[Label that is Long]-R servB
</pre>
<hr />
<hr />
<script type="module">
import mermaid from './mermaid.esm.mjs';
<script type="module">
import mermaid from './mermaid.esm.mjs';
const ALLOWED_TAGS = [
'a',
'b',
'blockquote',
'br',
'dd',
'div',
'dl',
'dt',
'em',
'foreignObject',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'h7',
'h8',
'hr',
'i',
'li',
'ul',
'ol',
'p',
'pre',
'span',
'strike',
'strong',
'table',
'tbody',
'td',
'tfoot',
'th',
'thead',
'tr',
];
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
theme: 'base',
startOnLoad: true,
logLevel: 0,
flowchart: {
useMaxWidth: false,
htmlLabels: true,
},
gantt: {
useMaxWidth: false,
},
architecture: {
iconSize: 80,
},
const ALLOWED_TAGS = [
'a',
'b',
'blockquote',
'br',
'dd',
'div',
'dl',
'dt',
'em',
'foreignObject',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'h7',
'h8',
'hr',
'i',
'li',
'ul',
'ol',
'p',
'pre',
'span',
'strike',
'strong',
'table',
'tbody',
'td',
'tfoot',
'th',
'thead',
'tr',
];
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
theme: 'base',
startOnLoad: true,
logLevel: 0,
flowchart: {
useMaxWidth: false,
});
function callback() {
alert('It worked');
}
mermaid.parseError = function (err, hash) {
console.error('In parse error:');
console.error(err);
};
</script>
</body>
</html>
htmlLabels: true,
},
gantt: {
useMaxWidth: false,
},
architecture: {
iconSize: 80,
},
useMaxWidth: false,
});
function callback() {
alert('It worked');
}
mermaid.parseError = function (err, hash) {
console.error('In parse error:');
console.error(err);
};
</script>
</body>
</html>