From 334f693d5d431e6f867af24267fc0466e43f1092 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 11 Jun 2024 11:15:23 +0800 Subject: [PATCH] :art: Repeat the escaped content of the image title https://github.com/siyuan-note/siyuan/issues/11681 --- kernel/go.mod | 2 +- kernel/go.sum | 4 ++-- kernel/model/box.go | 9 +++++++-- kernel/model/import.go | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/go.mod b/kernel/go.mod index e847bdb50f6..bf2f2bfce8e 100644 --- a/kernel/go.mod +++ b/kernel/go.mod @@ -8,7 +8,7 @@ require ( github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48 github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7 github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866 - github.com/88250/lute v1.7.7-0.20240607091414-8a2485a51a44 + github.com/88250/lute v1.7.7-0.20240611024745-53a7d0cc6568 github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4 diff --git a/kernel/go.sum b/kernel/go.sum index d756bc01484..a01a71076c7 100644 --- a/kernel/go.sum +++ b/kernel/go.sum @@ -12,8 +12,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866 h1:RFfNFS0hv6TbOuwET6xZAfGlV4hNlXiWTnfbLN1eF6k= github.com/88250/gulu v1.2.3-0.20240505150113-bc43bd50f866/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8= -github.com/88250/lute v1.7.7-0.20240607091414-8a2485a51a44 h1:8Vyd280GzTSO2+1KS7j8Ww0iYW/qF4rVkow4/YxSRO4= -github.com/88250/lute v1.7.7-0.20240607091414-8a2485a51a44/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk= +github.com/88250/lute v1.7.7-0.20240611024745-53a7d0cc6568 h1:1TwBQATNCmPi4XvEZReYDam8aouz3DZPXUciciTITdg= +github.com/88250/lute v1.7.7-0.20240611024745-53a7d0cc6568/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk= github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0= github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4= github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY= diff --git a/kernel/model/box.go b/kernel/model/box.go index fa56aa56796..3e5e100f441 100644 --- a/kernel/model/box.go +++ b/kernel/model/box.go @@ -429,11 +429,11 @@ func (box *Box) moveTrees0(files []*FileInfo) { func parseKTree(kramdown []byte) (ret *parse.Tree) { luteEngine := NewLute() ret = parse.Parse("", kramdown, luteEngine.ParseOptions) - genTreeID(ret) + normalizeTree(ret) return } -func genTreeID(tree *parse.Tree) { +func normalizeTree(tree *parse.Tree) { if nil == tree.Root.FirstChild { tree.Root.AppendChild(treenode.NewParagraph()) } @@ -494,6 +494,11 @@ func genTreeID(tree *parse.Tree) { n.InsertBefore(n.FirstChild) } + if ast.NodeLinkTitle == n.Type { + // 避免重复转义图片标题内容 Repeat the escaped content of the image title https://github.com/siyuan-note/siyuan/issues/11681 + n.Tokens = html.UnescapeBytes(n.Tokens) + } + return ast.WalkContinue }) tree.Root.KramdownIAL = parse.Tokens2IAL(tree.Root.LastChild.Tokens) diff --git a/kernel/model/import.go b/kernel/model/import.go index 6d09ed4ad64..332d707df8a 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -966,7 +966,7 @@ func parseStdMd(markdown []byte) (ret *parse.Tree) { if nil == ret { return } - genTreeID(ret) + normalizeTree(ret) imgHtmlBlock2InlineImg(ret) parse.NestedInlines2FlattedSpansHybrid(ret, false) return