将 rdview 底层全量替换为 rdtkview

This commit is contained in:
2026-10-05 16:32:09 +08:00
parent b3579bbd07
commit 52474483e8
24 changed files with 2313 additions and 2250 deletions
+30
View File
@@ -0,0 +1,30 @@
window.$docsify.plugins = [].concat(window.$docsify.plugins, (hook) => {
hook.doneEach(() => {
if (typeof window.RDViewRender !== "function") {
return;
}
const codeBlocks = document.querySelectorAll("pre[data-lang]");
codeBlocks.forEach((codeBlock) => {
const lang = codeBlock.getAttribute("data-lang") || "";
if (!lang.trim().startsWith("rdview")) {
return;
}
const codeEl = codeBlock.querySelector("code");
const code = codeEl ? codeEl.innerText : codeBlock.innerText;
let node;
try {
node = window.RDViewRender(lang, code);
} catch (e) {
console.error("rdview render failed:", lang, e);
return;
}
if (!node) {
return;
}
const parent = document.createElement("div");
parent.className = "rdtk-rdview-wrap";
parent.appendChild(node);
codeBlock.replaceWith(parent);
});
});
});