From 51d3c737fbf45f815c2f445c33733397207017bd Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 17 Jan 2025 23:31:58 +0800 Subject: [PATCH] :art: Improve code block parsing https://github.com/siyuan-note/siyuan/issues/13831 --- app/src/protyle/wysiwyg/input.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts index 2c261d68d..b1f97b09f 100644 --- a/app/src/protyle/wysiwyg/input.ts +++ b/app/src/protyle/wysiwyg/input.ts @@ -151,7 +151,7 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: if (trimStartText.indexOf("\n") === -1 && trimStartText.replace(/·|~/g, "`").replace(/^`{3,}/g, "").indexOf("`") > -1) { // ```test` 不处理,正常渲染为段落块 } else { - let replaceInnerHTML = editElement.innerHTML.replace(/^(~|·|`){3,}/g, "```").replace(/\n(~|·|`){3,}/g, "\n```").trim(); + let replaceInnerHTML = editElement.innerHTML.trim().replace(/^(~|·|`){3,}/g, "```").replace(/\n(~|·|`){3,}/g, "\n```").trim(); if (!replaceInnerHTML.endsWith("\n```")) { replaceInnerHTML = replaceInnerHTML.replace("", "") + "\n```"; }