From f8a706064a1315f1eb0ff49c24dcfc2f592f420d Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Mon, 31 Oct 2022 09:25:55 +0800 Subject: [PATCH] fix: fix show number line issue. --- package.json | 2 +- scripts/create.mjs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 118a993b..57575cc2 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "keywords": [], "devDependencies": { - "@wcj/markdown-to-html": "^2.1.1", + "@wcj/markdown-to-html": "^2.1.2", "chokidar": "^3.5.3", "fs-extra": "^10.1.0", "husky": "^8.0.1", diff --git a/scripts/create.mjs b/scripts/create.mjs index 5e819adf..81295720 100644 --- a/scripts/create.mjs +++ b/scripts/create.mjs @@ -48,13 +48,20 @@ export function create(str = '', options = {}) { ], filterPlugins: (type, plugins = []) => { if (type === 'rehype') { + let rehypePrism = null; const dt = plugins.filter((plug) => { - return /(rehypeRaw)/.test(plug.name) ? false : true; + if (Array.isArray(plug) && /(rehypePrism)/.test(plug[0].name)) { + rehypePrism = plug; + } + return /(rehypeRaw|rehypePrism)/.test(plug.name) ? false : true; }); // 放在 rehypeDocument 前面 dt.unshift(rehypeRaw); + if (rehypePrism) { + dt.unshift(rehypePrism); + } dt.unshift(rehypePreviewHTML); - return dt; + return plugins; } return plugins; },