const MarkdownRenderer = { init() { // 配置 marked.js marked.setOptions({ highlight: function(code, lang) { if (lang && hljs.getLanguage(lang)) { return hljs.highlight(code, { language: lang }).value; } return hljs.highlightAuto(code).value; }, breaks: true, gfm: true }); }, render(text) { if (!text) return ''; let html = marked.parse(text); // 为代码块添加复制按钮 html = html.replace(/
 {
            btn.textContent = '已复制';
            setTimeout(() => { btn.textContent = '复制'; }, 2000);
        });
    }
};

// 初始化
MarkdownRenderer.init();