fix: fix show number line issue.

This commit is contained in:
jaywcjlove 2022-10-31 09:25:55 +08:00
parent 48b5d0fba3
commit f8a706064a
2 changed files with 10 additions and 3 deletions

View File

@ -21,7 +21,7 @@
}, },
"keywords": [], "keywords": [],
"devDependencies": { "devDependencies": {
"@wcj/markdown-to-html": "^2.1.1", "@wcj/markdown-to-html": "^2.1.2",
"chokidar": "^3.5.3", "chokidar": "^3.5.3",
"fs-extra": "^10.1.0", "fs-extra": "^10.1.0",
"husky": "^8.0.1", "husky": "^8.0.1",

View File

@ -48,13 +48,20 @@ export function create(str = '', options = {}) {
], ],
filterPlugins: (type, plugins = []) => { filterPlugins: (type, plugins = []) => {
if (type === 'rehype') { if (type === 'rehype') {
let rehypePrism = null;
const dt = plugins.filter((plug) => { 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 前面 // 放在 rehypeDocument 前面
dt.unshift(rehypeRaw); dt.unshift(rehypeRaw);
if (rehypePrism) {
dt.unshift(rehypePrism);
}
dt.unshift(rehypePreviewHTML); dt.unshift(rehypePreviewHTML);
return dt; return plugins;
} }
return plugins; return plugins;
}, },