An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Preserve inbox titles when inserting into documents https://github.com/siyuan-note/siyuan/issues/19771
Daniele877da279b4c
diff --git a/app/src/layout/dock/Inbox.test.ts b/app/src/layout/dock/Inbox.test.tsindex 9efd43ca74..0baa7c79e4 100644--- a/app/src/layout/dock/Inbox.test.ts+++ b/app/src/layout/dock/Inbox.test.ts@@ -73,10 +73,10 @@ test("inbox insertion preserves link-only entries as Markdown links", async () =test("inbox insertion keeps Markdown punctuation in the title as plain text", async () => {const {inbox, calls, removed} = loadInbox([- {code: 0, data: {shorthandMd: "Body", shorthandTitle: "A *bold* [note]\ncontinued"}},+ {code: 0, data: {shorthandMd: "Body", shorthandTitle: "A *bold* [note] $x$ ==mark== & #tag#\ncontinued"}},{code: 0},]);await inbox.insertToCurrentDoc(["entry"], "doc-id");- assert.equal(calls[1].data.data, "# A \\*bold\\* \\[note\\] continued\n\nBody");+ assert.equal(calls[1].data.data, "# A \\*bold\\* \\[note\\] \\$x\\$ \\=\\=mark\\=\\= \\&\\; \\#tag\\# continued\n\nBody");assert.deepEqual(removed, [["entry"]]);});diff --git a/app/src/layout/dock/Inbox.ts b/app/src/layout/dock/Inbox.tsindex 3d53203fff..1238e788d0 100644--- a/app/src/layout/dock/Inbox.ts+++ b/app/src/layout/dock/Inbox.ts@@ -421,8 +421,9 @@ ${data.shorthandContent}if (!md && !shorthand.data.shorthandContent && shorthand.data.shorthandURL) {md = `[${shorthand.data.shorthandTitle}](${shorthand.data.shorthandURL})`;}+ // 转义 ASCII 标点,避免剪藏标题中的符号被解析为行内语法。const title = shorthand.data.shorthandTitle.replace(/[\r\n]+/g, " ").trim()- .replace(/[\\`*_{}\[\]()#+\-.!>|~]/g, "\\$&");+ .replace(/[\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/g, "\\$&");if (title) {md = `# ${title}\n\n${md}`;}