This commit is contained in:
Liang Ding 2023-01-27 21:14:09 +08:00
parent 9589dbbc7b
commit 04f47749f7
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
19 changed files with 295 additions and 34 deletions

View file

@ -138,7 +138,7 @@ func SwapBlockRef(refID, defID string, includeChildren bool) (err error) {
}
}
refPivot := parse.NewParagraph()
refPivot := treenode.NewParagraph()
refNode.InsertBefore(refPivot)
if ast.NodeListItem == defNode.Type {

View file

@ -425,7 +425,7 @@ func parseKTree(kramdown []byte) (ret *parse.Tree) {
func genTreeID(tree *parse.Tree) {
if nil == tree.Root.FirstChild {
tree.Root.AppendChild(parse.NewParagraph())
tree.Root.AppendChild(treenode.NewParagraph())
}
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {

View file

@ -447,6 +447,11 @@ func getMarkSpanEnd() string {
}
func GetDoc(startID, endID, id string, index int, keyword string, mode int, size int, isBacklink bool) (blockCount, childBlockCount int, dom, parentID, parent2ID, rootID, typ string, eof bool, boxID, docPath string, isBacklinkExpand bool, err error) {
//os.MkdirAll("pprof", 0755)
//cpuProfile, _ := os.Create("pprof/GetDoc")
//pprof.StartCPUProfile(cpuProfile)
//defer pprof.StopCPUProfile()
WaitForWritingFiles() // 写入数据时阻塞,避免获取到的数据不一致
inputIndex := index
@ -1451,7 +1456,7 @@ func createDoc(boxID, p, title, dom string) (tree *parse.Tree, err error) {
updated := util.TimeFromID(id)
tree.Root.KramdownIAL = [][]string{{"id", id}, {"title", html.EscapeAttrVal(title)}, {"updated", updated}}
if nil == tree.Root.FirstChild {
tree.Root.AppendChild(parse.NewParagraph())
tree.Root.AppendChild(treenode.NewParagraph())
}
transaction := &Transaction{DoOperations: []*Operation{{Action: "create", Data: tree}}}

View file

@ -166,7 +166,7 @@ func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath st
if "" != tagIAL && 0 < len(tags) {
// 带标签的文档块转换为标题块时将标签移动到标题块下方 https://github.com/siyuan-note/siyuan/issues/6550
tagPara := parse.NewParagraph()
tagPara := treenode.NewParagraph()
for i, tag := range tags {
if "" == tag {
continue
@ -319,7 +319,7 @@ func Heading2Doc(srcHeadingID, targetBoxID, targetPath string) (srcRootBlockID,
headingNode.Unlink()
srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
if nil == srcTree.Root.FirstChild {
srcTree.Root.AppendChild(parse.NewParagraph())
srcTree.Root.AppendChild(treenode.NewParagraph())
}
if err = indexWriteJSONQueue(srcTree); nil != err {
return "", "", err

View file

@ -19,7 +19,6 @@ package model
import (
"encoding/json"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"io/fs"
"math"
"os"
@ -37,8 +36,10 @@ import (
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -154,7 +155,7 @@ func GetDocHistoryContent(historyPath, keyword string) (id, rootID, content stri
isLargeDoc = 1024*1024*1 <= len(data)
luteEngine := NewLute()
historyTree, err := parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
historyTree, err := filesys.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
if nil != err {
logging.LogErrorf("parse tree from file [%s] failed, remove it", historyPath)
os.RemoveAll(historyPath)

View file

@ -45,6 +45,7 @@ import (
"github.com/88250/lute/render"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
@ -125,7 +126,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
err = readErr
return
}
tree, _, parseErr := parse.ParseJSON(data, luteEngine.ParseOptions)
tree, _, parseErr := filesys.ParseJSON(data, luteEngine.ParseOptions)
if nil != parseErr {
logging.LogErrorf("parse .sy [%s] failed: %s", syPath, parseErr)
err = parseErr

View file

@ -72,7 +72,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
children = append(children, c)
}
if 1 > len(children) {
newNode := parse.NewParagraph()
newNode := treenode.NewParagraph()
children = append(children, newNode)
}
@ -96,7 +96,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
}
srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
if nil == srcTree.Root.FirstChild {
srcTree.Root.AppendChild(parse.NewParagraph())
srcTree.Root.AppendChild(treenode.NewParagraph())
}
if err = indexWriteJSONQueue(srcTree); nil != err {
return "", "", err

View file

@ -23,7 +23,6 @@ import (
"encoding/base64"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"math"
"net/http"
"os"
@ -49,7 +48,9 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/studio-b12/gowebdav"
@ -255,7 +256,7 @@ func parseTitleInSnapshot(fileID string, repo *dejavu.Repo, luteEngine *lute.Lut
}
var tree *parse.Tree
tree, err = parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
tree, err = filesys.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
if nil != err {
logging.LogErrorf("parse file [%s] failed: %s", fileID, err)
return
@ -277,7 +278,7 @@ func parseTreeInSnapshot(fileID string, repo *dejavu.Repo, luteEngine *lute.Lute
}
isLargeDoc = 1024*1024*1 <= len(data)
tree, err = parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
tree, err = filesys.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
if nil != err {
return
}

View file

@ -20,13 +20,6 @@ import (
"bytes"
"errors"
"fmt"
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
"github.com/araddon/dateparse"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"io/fs"
"os"
"path/filepath"
@ -36,9 +29,16 @@ import (
"time"
"github.com/88250/gulu"
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
sprig "github.com/Masterminds/sprig/v3"
"github.com/araddon/dateparse"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
func RenderGoTemplate(templateContent string) (ret string, err error) {
@ -258,7 +258,7 @@ func renderTemplate(p, id string) (string, error) {
return ast.WalkContinue
})
for _, n := range nodesNeedAppendChild {
n.AppendChild(parse.NewParagraph())
n.AppendChild(treenode.NewParagraph())
}
for _, n := range unlinks {
n.Unlink()

View file

@ -131,7 +131,7 @@ func loadTree(localPath string, luteEngine *lute.Lute) (ret *parse.Tree, err err
return
}
ret, err = parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
ret, err = filesys.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
if nil != err {
logging.LogErrorf("parse json to tree [%s] failed: %s", localPath, err)
return

View file

@ -22,9 +22,8 @@ import (
"strings"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/util"
)
func SearchWidget(keyword string) (ret []*Block) {