Skip to content

Commit 883e631

Browse files
fix(migrate): remove \\\mdx`
1 parent ba9c68a commit 883e631

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

migrate/migrate-bot.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,13 @@ ${html}
9999
}
100100

101101
const data = await response.json();
102-
return data.choices[0].message.content.trim();
102+
const content = data.choices[0].message.content.trim();
103+
104+
if (content.includes('```mdx')) {
105+
return content.replace(/```mdx\s*([\s\S]*?)\s*```/g, "$1").trim();
106+
}
107+
108+
return content;
103109
}
104110

105111
function getLocalPath(url) {
@@ -220,24 +226,19 @@ async function main() {
220226
throw new Error("标题中未找到有效的cppreference链接");
221227
}
222228

223-
// 获取页面内容
224229
console.log(` 获取 ${url}`);
225230
const { html, title } = await fetchPageContent(url);
226231

227-
// 转换为MDX
228232
console.log(` 转换HTML为MDX...`);
229233
const mdx = await convertToMDX(html, title, url);
230234

231-
// 写入文件
232235
const filePath = getLocalPath(url);
233236
console.log(` 写入 ${filePath}`);
234237
await writeMDXFile(filePath, mdx, title);
235238

236-
// 创建PR
237239
console.log(` 创建PR...`);
238240
const prNumber = await createPullRequest(issue, filePath, url);
239241

240-
// 更新issue
241242
console.log(` 更新issue...`);
242243
await updateIssue(issue, prNumber);
243244

0 commit comments

Comments
 (0)