Ver código fonte

:art: Repeat the escaped content of the image title https://github.com/siyuan-note/siyuan/issues/11681

Daniel 1 ano atrás
pai
commit
334f693d5d
4 arquivos alterados com 11 adições e 6 exclusões
  1. 1 1
      kernel/go.mod
  2. 2 2
      kernel/go.sum
  3. 7 2
      kernel/model/box.go
  4. 1 1
      kernel/model/import.go

+ 1 - 1
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

+ 2 - 2
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=

+ 7 - 2
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)

+ 1 - 1
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