Skip to content

Commit

Permalink
🎨 Repeat the escaped content of the image title #11681
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jun 11, 2024
1 parent 519b004 commit 334f693
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion kernel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions kernel/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
9 changes: 7 additions & 2 deletions kernel/model/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion kernel/model/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 334f693

Please sign in to comment.