fix: 修复 esbuild 正则/模板字面量解析问题(反引号兼容性)

This commit is contained in:
Metona Build
2026-04-19 17:52:57 +08:00
parent f817abd5e1
commit a8fe322b67
3 changed files with 16 additions and 8 deletions
+2 -1
View File
@@ -12,7 +12,8 @@ function parseMarkdown(md: string): string {
let html = escapeForMd(md);
// 代码块 ```...```
html = html.replace(/```(\w*)\n([\s\S]*?)```/g, (_m, lang, code) => {
const codeBlockRe = new RegExp('```(\\w*)\\n([\\s\\S]*?)```', 'g');
html = html.replace(codeBlockRe, (_m, lang, code) => {
return `<pre><code class="language-${lang}">${code.trim()}</code></pre>`;
});