改进建立引用索引 https://github.com/siyuan-note/siyuan/issues/7320
This commit is contained in:
Liang Ding 2023-02-10 14:28:10 +08:00
parent 6743b21193
commit b6ea32462e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
23 changed files with 155 additions and 132 deletions

View file

@ -17,14 +17,15 @@
package api
import (
"github.com/siyuan-note/siyuan/kernel/treenode"
"net/http"
"github.com/88250/gulu"
"github.com/88250/lute"
"github.com/88250/lute/ast"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -44,7 +45,7 @@ func appendBlock(c *gin.Context) {
return
}
if "markdown" == dataType {
luteEngine := model.NewLute()
luteEngine := util.NewLute()
data = dataBlockDOM(data, luteEngine)
}
@ -89,7 +90,7 @@ func prependBlock(c *gin.Context) {
return
}
if "markdown" == dataType {
luteEngine := model.NewLute()
luteEngine := util.NewLute()
data = dataBlockDOM(data, luteEngine)
}
@ -150,7 +151,7 @@ func insertBlock(c *gin.Context) {
}
if "markdown" == dataType {
luteEngine := model.NewLute()
luteEngine := util.NewLute()
data = dataBlockDOM(data, luteEngine)
}
@ -197,7 +198,7 @@ func updateBlock(c *gin.Context) {
return
}
luteEngine := model.NewLute()
luteEngine := util.NewLute()
if "markdown" == dataType {
data = dataBlockDOM(data, luteEngine)
}
@ -217,7 +218,7 @@ func updateBlock(c *gin.Context) {
var transactions []*model.Transaction
if "NodeDocument" == block.Type {
oldTree, err := model.LoadTree(block.Box, block.Path)
oldTree, err := filesys.LoadTree(block.Box, block.Path, luteEngine)
if nil != err {
ret.Code = -1
ret.Msg = "load tree failed: " + err.Error()

View file

@ -28,6 +28,7 @@ import (
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -86,7 +87,8 @@ func heading2Doc(c *gin.Context) {
}
model.WaitForWritingFiles()
tree, err := model.LoadTree(targetNotebook, targetPath)
luteEngine := util.NewLute()
tree, err := filesys.LoadTree(targetNotebook, targetPath, luteEngine)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@ -130,7 +132,8 @@ func li2Doc(c *gin.Context) {
}
model.WaitForWritingFiles()
tree, err := model.LoadTree(targetNotebook, targetPath)
luteEngine := util.NewLute()
tree, err := filesys.LoadTree(targetNotebook, targetPath, luteEngine)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@ -424,7 +427,8 @@ func createDailyNote(c *gin.Context) {
box := model.Conf.Box(notebook)
model.WaitForWritingFiles()
tree, err := model.LoadTree(box.ID, p)
luteEngine := util.NewLute()
tree, err := filesys.LoadTree(box.ID, p, luteEngine)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()

View file

@ -62,7 +62,7 @@ func html2BlockDOM(c *gin.Context) {
return
}
luteEngine := model.NewLute()
luteEngine := util.NewLute()
var unlinks []*ast.Node
tree := parse.Parse("", []byte(markdown), luteEngine.ParseOptions)
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {