Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16519

Vanessafa9cf01c620c
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index 176892894d..a5e2cc0f98 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -167,7 +167,11 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
// ```test` 不处理,正常渲染为段落块
} else {
let replaceInnerHTML = editElement.innerHTML.trim().replace(/^(~|·|`){3,}/g, "```").replace(/\n(~|·|`){3,}/g, "\n```").trim();
- if (!replaceInnerHTML.endsWith("\n```") && !replaceInnerHTML.endsWith("\n```<wbr>")) {
+ if (replaceInnerHTML.endsWith("\n```<wbr>") &&
+ (replaceInnerHTML.split("\n```").length - 1 + (replaceInnerHTML.startsWith("```") ? 1 : 0)) % 2 === 0) {
+ // 匹配已闭合的不需添加 https://github.com/siyuan-note/siyuan/issues/16053
+ } else if (!replaceInnerHTML.endsWith("\n```")) {
+ // 以 "\n```<wbr>" 结尾需要添加的情况 https://github.com/siyuan-note/siyuan/issues/16519
replaceInnerHTML = replaceInnerHTML.replace("<wbr>", "") + "<wbr>\n```";
}
editElement.innerHTML = replaceInnerHTML;