diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts index 3da8e6d9c..bdb7c6b83 100644 --- a/app/src/protyle/header/Title.ts +++ b/app/src/protyle/header/Title.ts @@ -104,8 +104,12 @@ export class Title { event.stopPropagation(); let textPlain = await readText() || ""; if (textPlain) { + // 对 <> 进行内部转义 https://github.com/siyuan-note/siyuan/issues/11992 + textPlain = textPlain.replace(/<>/g, "__@gt2@__"); // 对 HTML 标签进行内部转义,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620 textPlain = textPlain.replace(//g, ";;;gt;;;"); + // 反转义 <> + textPlain = textPlain.replace(/__@lt2assets\/@__/g, "<>"); enableLuteMarkdownSyntax(protyle); let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain)); restoreLuteMarkdownSyntax(protyle); @@ -273,7 +277,9 @@ export class Title { accelerator: "⇧⌘V", click: async () => { let textPlain = await readText() || ""; + textPlain = textPlain.replace(/<>/g, "__@gt2@__"); textPlain = textPlain.replace(//g, ";;;gt;;;"); + textPlain = textPlain.replace(/__@lt2assets\/@__/g, "<>"); enableLuteMarkdownSyntax(protyle); let content = protyle.lute.BlockDOM2EscapeMarkerContent(protyle.lute.Md2BlockDOM(textPlain)); restoreLuteMarkdownSyntax(protyle); diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts index 741aaea82..38ddd10ee 100644 --- a/app/src/protyle/util/paste.ts +++ b/app/src/protyle/util/paste.ts @@ -175,9 +175,15 @@ export const pasteAsPlainText = async (protyle: IProtyle) => { // 删掉 text 标签,只保留文本 textPlain = textPlain.replace(/(.*?)<\/span>/g, "$1"); + // 对 <> 进行内部转义 https://github.com/siyuan-note/siyuan/issues/11992 + textPlain = textPlain.replace(/<>/g, "__@gt2@__"); + // 对 HTML 标签进行内部转义,避免被 Lute 解析以后变为小写 https://github.com/siyuan-note/siyuan/issues/10620 textPlain = textPlain.replace(//g, ";;;gt;;;"); + // 反转义 <> + textPlain = textPlain.replace(/__@lt2assets\/@__/g, "<>"); + // 反转义内置需要解析的 HTML 标签 textPlain = textPlain.replace(/__@sub@__/g, "").replace(/__@\/sub@__/g, ""); textPlain = textPlain.replace(/__@sup@__/g, "").replace(/__@\/sup@__/g, "");