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); }); }); });