From 688514a6991a015977fd4e1eb9750671359242dd Mon Sep 17 00:00:00 2001 From: yanmao <55792257+yanmao-cc@users.noreply.github.com> Date: Wed, 15 Jun 2022 23:31:12 +0800 Subject: [PATCH] fix(codeblock): When parsing markdown, there will be an extra line at the end --- plugins/codeblock-vue/src/index.ts | 3 +++ plugins/codeblock/src/index.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plugins/codeblock-vue/src/index.ts b/plugins/codeblock-vue/src/index.ts index aa20cbb19..68ca190f6 100644 --- a/plugins/codeblock-vue/src/index.ts +++ b/plugins/codeblock-vue/src/index.ts @@ -177,6 +177,9 @@ export default class< false, ); code = unescape(code.replace(/\u200b/g, '')); + if (code.endsWith('\n')) { + code = code.slice(0, -1); + } editor.card.replaceNode(node, 'codeblock', { mode: syntax || 'plain', code, diff --git a/plugins/codeblock/src/index.ts b/plugins/codeblock/src/index.ts index ee75e550a..9651dc795 100644 --- a/plugins/codeblock/src/index.ts +++ b/plugins/codeblock/src/index.ts @@ -177,6 +177,9 @@ export default class< false, ); code = unescape(code.replace(/\u200b/g, '')); + if (code.endsWith('\n')) { + code = code.slice(0, -1); + } editor.card.replaceNode(node, 'codeblock', { mode: syntax || 'plain', code,