From 2f54fc0b8ad4e69e0912aa969cb60be77d5e6b9e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 25 Oct 2022 20:16:32 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=B8=B2=E6=9F=93=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E5=92=8C=E6=90=9C=E7=B4=A2=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20Markdown=20=E6=A0=87=E8=AE=B0=E7=AC=A6?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=A7=A3=E6=9E=90=20Fix=20https://github.com?= =?UTF-8?q?/siyuan-note/siyuan/issues/6352?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/backlink.go | 2 ++ kernel/model/file.go | 3 +++ kernel/model/history.go | 2 ++ 3 files changed, 7 insertions(+) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index efafd41cd..5b1b6d38f 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -28,6 +28,7 @@ import ( "github.com/88250/gulu" "github.com/88250/lute" "github.com/88250/lute/ast" + "github.com/88250/lute/lex" "github.com/88250/lute/parse" "github.com/emirpasic/gods/sets/hashset" "github.com/facette/natsort" @@ -308,6 +309,7 @@ func buildBacklink(refID string, refTree *parse.Tree, mentionKeywords []string, n.Tokens = gulu.Str.ToBytes(newText) if bytes.Contains(n.Tokens, []byte("search-mark")) { n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\"+searchMarkSpanStart), []byte("\\\\"+searchMarkSpanEnd)) + n.Tokens = lex.EscapeMarkers(n.Tokens) linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions) var children []*ast.Node for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next { diff --git a/kernel/model/file.go b/kernel/model/file.go index f30bd15a2..da6bd4c20 100644 --- a/kernel/model/file.go +++ b/kernel/model/file.go @@ -34,6 +34,7 @@ import ( "github.com/88250/gulu" "github.com/88250/lute/ast" "github.com/88250/lute/html" + "github.com/88250/lute/lex" "github.com/88250/lute/parse" util2 "github.com/88250/lute/util" "github.com/dustin/go-humanize" @@ -665,6 +666,7 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size n.Tokens = gulu.Str.ToBytes(text) if bytes.Contains(n.Tokens, []byte("search-mark")) { n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\"+searchMarkSpanStart), []byte("\\\\"+searchMarkSpanEnd)) + n.Tokens = lex.EscapeMarkers(n.Tokens) linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions) var children []*ast.Node for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next { @@ -704,6 +706,7 @@ func GetDoc(startID, endID, id string, index int, keyword string, mode int, size } n.Tokens = []byte(newContent) + n.Tokens = lex.EscapeMarkers(n.Tokens) linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions) var children []*ast.Node for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next { diff --git a/kernel/model/history.go b/kernel/model/history.go index 854c4ea69..7a7945fc9 100644 --- a/kernel/model/history.go +++ b/kernel/model/history.go @@ -32,6 +32,7 @@ import ( "github.com/88250/gulu" "github.com/88250/lute" "github.com/88250/lute/ast" + "github.com/88250/lute/lex" "github.com/88250/lute/parse" "github.com/88250/lute/render" "github.com/siyuan-note/filelock" @@ -186,6 +187,7 @@ func GetDocHistoryContent(historyPath, keyword string) (id, rootID, content stri n.Tokens = gulu.Str.ToBytes(text) if bytes.Contains(n.Tokens, []byte("search-mark")) { n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("\\"+searchMarkSpanStart), []byte("\\\\"+searchMarkSpanStart)) + n.Tokens = lex.EscapeMarkers(n.Tokens) linkTree := parse.Inline("", n.Tokens, luteEngine.ParseOptions) var children []*ast.Node for c := linkTree.Root.FirstChild.FirstChild; nil != c; c = c.Next {