Skip to content

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

:art: mprove pasting of inline code containing backticks https://github.com/siyuan-note/siyuan/issues/17388

Daniel7771b1ca3bb5
diff --git a/app/src/protyle/util/processCode.ts b/app/src/protyle/util/processCode.ts
index 7e66547926..373a8a7d15 100644
--- a/app/src/protyle/util/processCode.ts
+++ b/app/src/protyle/util/processCode.ts
@@ -38,6 +38,10 @@ export const processPasteCode = (html: string, text: string, originalTextHTML: s
} else {
// Paste code from IDE no longer escape `<` and `>` https://github.com/siyuan-note/siyuan/issues/8340
code = code.replace(/</g, "&lt;").replace(/>/g, "&gt;");
+ // Improve pasting of inline code containing backticks https://github.com/siyuan-note/siyuan/issues/17388
+ if (-1 < code.indexOf("`")) {
+ return "``" + code + "``"; // ``foo `bar` baz``
+ }
return "`" + code + "`";
}
}