File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @interledger/docs-design-system" ,
3- "version" : " 0.10.1 " ,
3+ "version" : " 0.10.2 " ,
44 "type" : " module" ,
55 "description" : " Shared styles and components used across all Interledger Starlight documentation sites" ,
66 "exports" : {
Original file line number Diff line number Diff line change @@ -24,5 +24,26 @@ const { graph, hasBorder = false } = Astro.props;
2424
2525<script >
2626 import mermaid from "/node_modules/mermaid/dist/mermaid.esm.min.mjs";
27- mermaid.initialize({ startOnLoad: true });
27+ mermaid.initialize({ startOnLoad: false });
28+
29+ const mermaidElements = document.querySelectorAll("pre.mermaid");
30+
31+ function unescapeHTML(str) {
32+ return str
33+ .replaceAll(">", ">")
34+ .replaceAll("<", "<")
35+ .replaceAll("&", "&");
36+ }
37+
38+ async function drawDiagram(mermaidElement) {
39+ let graphDefinition = mermaidElement.innerHTML;
40+ graphDefinition = unescapeHTML(graphDefinition);
41+ const id = `graphDiv${Math.floor(Math.random() * 10000)}`;
42+ const { svg } = await mermaid.render(id, graphDefinition);
43+ mermaidElement.innerHTML = svg;
44+ }
45+
46+ for (let mermaidElement of mermaidElements) {
47+ await drawDiagram(mermaidElement);
48+ }
2849</script >
You can’t perform that action at this time.
0 commit comments