PageSourceSearch

https://office365eksperten.dk/javascripts/mermaid-init.js

js office365eksperten.dk collected 2026-10-04 08:09:31 UTC 1,573 bytes, 47 lines download raw bytes

1/* =========================================================
2   Mermaid init - læser Material's color scheme og initialiserer Mermaid
3   for alle <pre class="mermaid"> blokke (genereret af pymdownx.superfences).
4   Håndterer også theme-skift (lys/mørk).
5   ========================================================= */
6
7(function () {
8  function getMermaidTheme() {
9    var scheme = document.body.getAttribute("data-md-color-scheme");
10    return scheme === "slate" ? "dark" : "default";
11  }
12
13  function unwrapCodeBlocks() {
14    // pymdownx.superfences pakker mermaid ind i <pre class="mermaid"><code>...</code></pre>.
15    // Mermaid v10 vil have indholdet direkte i <pre> uden <code>-wrapper.
16    var blocks = document.querySelectorAll("pre.mermaid > code");
17    blocks.forEach(function (code) {
18      var pre = code.parentElement;
19      // Brug textContent - bevarer originalt mermaid-source uden HTML-entities
20      pre.textContent = code.textContent;
21    });
22  }
23
24  function init() {
25    if (typeof mermaid === "undefined") return;
26
27    unwrapCodeBlocks();
28
29    mermaid.initialize({
30      startOnLoad: false,
31      theme: getMermaidTheme(),
32      securityLevel: "loose",
33      flowchart: { useMaxWidth: true, htmlLabels: true, curve: "basis" }
34    });
35
36    // Render alle .mermaid-elementer
37    mermaid.run({ querySelector: "pre.mermaid, .mermaid" }).catch(function (e) {
38      console.warn("Mermaid render failed:", e);
39    });
40  }
41
42  if (document.readyState === "loading") {
43    document.addEventListener("DOMContentLoaded", init);
44  } else {
45    init();
46  }
47})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.