1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
(function() {
var el = document.getElementById("Showdown-script");
function isRelativeLink(href) {
if (!href || href.charAt(0) === "#") return false;
if (href.charAt(0) === "/") return false;
if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return false;
if (href.indexOf("//") === 0) return false;
return true;
}
function rewriteRelativeLinks(container, blobBase, blobDir) {
if (!blobBase) return;
var links = container.querySelectorAll("a[href]");
for (var i = 0; i < links.length; i++) {
var a = links[i];
var href = a.getAttribute("href");
if (href && isRelativeLink(href)) {
var path = href.replace(/^\.\//, "");
var fullPath = blobDir ? blobDir + "/" + path : path;
a.setAttribute("href", blobBase + encodeURIComponent(fullPath));
}
}
}
function slugifyId(id) {
if (!id) return "";
return id.replace(/\s+/g, "-").replace(/[^\w-]/g, "").toLowerCase();
}
function ensureHeadingIds(container) {
var headings = container.querySelectorAll("h1, h2, h3, h4, h5, h6");
for (var i = 0; i < headings.length; i++) {
var h = headings[i];
if (!h.id) {
var text = (h.textContent || "").trim();
var base = slugifyId(text) || "section";
var id = base;
var n = 0;
while (container.ownerDocument.getElementById(id)) id = base + "-" + (++n);
h.id = id;
}
}
}
function addSectionLinks(container) {
var headings = container.querySelectorAll("h1, h2, h3, h4, h5, h6");
for (var i = 0; i < headings.length; i++) {
var h = headings[i];
var id = h.id;
if (!id) continue;
var wrap = document.createElement("span");
wrap.className = "readme-heading-wrap";
h.parentNode.insertBefore(wrap, h);
wrap.appendChild(h);
var anchor = document.createElement("a");
anchor.href = "#" + id;
anchor.className = "readme-section-anchor";
anchor.setAttribute("aria-label", "Copy link to section");
anchor.textContent = "\u00A7";
anchor.addEventListener("click", function(e) {
e.preventDefault();
var targetId = this.getAttribute("href").slice(1);
var url = window.location.origin + window.location.pathname + window.location.search + "#" + targetId;
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(url);
} else {
window.location.hash = targetId;
}
});
wrap.insertBefore(anchor, h);
}
}
function buildToc(container) {
var headings = container.querySelectorAll("h1, h2, h3, h4, h5, h6");
if (headings.length === 0) return null;
var nav = document.createElement("nav");
nav.className = "readme-toc";
nav.setAttribute("aria-label", "Table of contents");
var list = document.createElement("ul");
list.className = "readme-toc-list";
var tagLevel = { H1: 1, H2: 2, H3: 3, H4: 4, H5: 5, H6: 6 };
for (var i = 0; i < headings.length; i++) {
var h = headings[i];
var id = h.id;
if (!id) continue;
var level = tagLevel[h.tagName] || 1;
var li = document.createElement("li");
li.className = "readme-toc-item readme-toc-level-" + level;
li.setAttribute("data-id", id);
var a = document.createElement("a");
a.href = "#" + id;
a.className = "readme-toc-link";
a.textContent = (h.textContent || "").trim();
a.addEventListener("click", function(e) {
e.preventDefault();
var targetId = this.getAttribute("href").slice(1);
var target = document.getElementById(targetId);
if (target) target.scrollIntoView({ behavior: "smooth", block: "start" });
if (history.replaceState) history.replaceState(null, "", "#" + targetId);
});
li.appendChild(a);
list.appendChild(li);
}
nav.appendChild(list);
return nav;
}
function mountTocAndScrollSpy(tocEl, container) {
var page = document.querySelector(".page");
if (!page) return;
var tocPlaceholder = document.createElement("div");
tocPlaceholder.className = "readme-toc-mount";
page.appendChild(tocPlaceholder);
tocPlaceholder.appendChild(tocEl);
var links = tocEl.querySelectorAll(".readme-toc-link");
var items = tocEl.querySelectorAll(".readme-toc-item");
function updateActive() {
var fromTop = window.scrollY + 8;
var current = null;
var headings = container.querySelectorAll("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]");
for (var i = headings.length - 1; i >= 0; i--) {
if (headings[i].getBoundingClientRect().top + window.scrollY <= fromTop) {
current = headings[i].id;
break;
}
}
if (!current && headings.length) current = headings[0].id;
for (var j = 0; j < items.length; j++) {
var on = items[j].getAttribute("data-id") === current;
items[j].classList.toggle("readme-toc-active", on);
}
}
var ticking = false;
function onScroll() {
if (!ticking) {
requestAnimationFrame(function() {
updateActive();
ticking = false;
});
ticking = true;
}
}
window.addEventListener("scroll", onScroll, { passive: true });
updateActive();
}
function b64ToUtf8(b64) {
var binary = atob(b64);
var bytes = new Uint8Array(binary.length);
for (var i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
return new TextDecoder().decode(bytes);
}
function render() {
var container = document.getElementById("readme-container");
var enc = container && container.getAttribute("data-readme-b64");
var blobBase = container && container.getAttribute("data-blob-base");
var blobDir = container && container.getAttribute("data-blob-dir") || "";
if (!container || !enc || typeof showdown === "undefined") return;
try {
var raw = b64ToUtf8(enc);
var conv = new showdown.Converter({ ghCompatibleHeaderId: true });
container.innerHTML = conv.makeHtml(raw);
ensureHeadingIds(container);
rewriteRelativeLinks(container, blobBase, blobDir);
addSectionLinks(container);
var toc = buildToc(container);
if (toc) mountTocAndScrollSpy(toc, container);
} catch (e) {}
}
if (el) {
if (el.getAttribute("data-loaded")) render();
else el.addEventListener("load", function() { el.setAttribute("data-loaded", "1"); render(); });
}
})();