mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-29 19:56:10 +01:00
♻️ 将解析渲染器 Protyle 项目合并到 Lute 项目中 https://github.com/siyuan-note/siyuan/issues/5602
This commit is contained in:
parent
929b27b7f6
commit
dc193ce904
13 changed files with 55 additions and 46 deletions
|
|
@ -36,7 +36,6 @@ import (
|
|||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/lute/render"
|
||||
util2 "github.com/88250/lute/util"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/facette/natsort"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
|
@ -1426,7 +1425,7 @@ func createDoc(boxID, p, title, dom string) (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(protyle.NewParagraph())
|
||||
tree.Root.AppendChild(parse.NewParagraph())
|
||||
}
|
||||
|
||||
transaction := &Transaction{DoOperations: []*Operation{{Action: "create", Data: tree}}}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
|
@ -299,7 +298,7 @@ func Heading2Doc(srcHeadingID, targetBoxID, targetPath string) (srcRootBlockID,
|
|||
headingNode.Unlink()
|
||||
srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
|
||||
if nil == srcTree.Root.FirstChild {
|
||||
srcTree.Root.AppendChild(protyle.NewParagraph())
|
||||
srcTree.Root.AppendChild(parse.NewParagraph())
|
||||
}
|
||||
if err = indexWriteJSONQueue(srcTree); nil != err {
|
||||
return "", "", err
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/conf"
|
||||
|
|
@ -140,7 +140,7 @@ func GetDocHistoryContent(historyPath string) (content string, err error) {
|
|||
return
|
||||
}
|
||||
luteEngine := NewLute()
|
||||
historyTree, err := protyle.ParseJSONWithoutFix(luteEngine, data)
|
||||
historyTree, err := parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
|
||||
if nil != err {
|
||||
logging.LogErrorf("parse tree from file [%s] failed, remove it", historyPath)
|
||||
os.RemoveAll(historyPath)
|
||||
|
|
@ -291,7 +291,7 @@ func GetDocHistory(boxID string) (ret []*History, err error) {
|
|||
logging.LogErrorf("read file [%s] failed: %s", path, err)
|
||||
return nil
|
||||
}
|
||||
historyTree, err := protyle.ParseJSONWithoutFix(luteEngine, data)
|
||||
historyTree, err := parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
|
||||
if nil != err {
|
||||
logging.LogErrorf("parse tree from file [%s] failed, remove it", path)
|
||||
os.RemoveAll(path)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import (
|
|||
"github.com/88250/lute/html"
|
||||
"github.com/88250/lute/html/atom"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/88250/lute/render"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
|
|
@ -94,7 +94,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
err = readErr
|
||||
return
|
||||
}
|
||||
tree, _, parseErr := protyle.ParseJSON(luteEngine, data)
|
||||
tree, _, parseErr := parse.ParseJSON(data, luteEngine.ParseOptions)
|
||||
if nil != parseErr {
|
||||
logging.LogErrorf("parse .sy [%s] failed: %s", syPath, parseErr)
|
||||
err = parseErr
|
||||
|
|
@ -144,7 +144,7 @@ func ImportSY(zipPath, boxID, toPath string) (err error) {
|
|||
// 写回 .sy
|
||||
for _, tree := range trees {
|
||||
syPath := filepath.Join(unzipRootPath, tree.Path)
|
||||
renderer := protyle.NewJSONRenderer(tree, luteEngine.RenderOptions)
|
||||
renderer := render.NewJSONRenderer(tree, luteEngine.RenderOptions)
|
||||
data := renderer.Render()
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -73,7 +72,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
|
|||
children = append(children, c)
|
||||
}
|
||||
if 1 > len(children) {
|
||||
newNode := protyle.NewParagraph()
|
||||
newNode := parse.NewParagraph()
|
||||
children = append(children, newNode)
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +95,7 @@ func ListItem2Doc(srcListItemID, targetBoxID, targetPath string) (srcRootBlockID
|
|||
}
|
||||
srcTree.Root.SetIALAttr("updated", util.CurrentTimeSecondsStr())
|
||||
if nil == srcTree.Root.FirstChild {
|
||||
srcTree.Root.AppendChild(protyle.NewParagraph())
|
||||
srcTree.Root.AppendChild(parse.NewParagraph())
|
||||
}
|
||||
if err = indexWriteJSONQueue(srcTree); nil != err {
|
||||
return "", "", err
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import (
|
|||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/lute/render"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/araddon/dateparse"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
|
@ -215,7 +214,7 @@ func renderTemplate(p, id string) (string, error) {
|
|||
return ast.WalkContinue
|
||||
})
|
||||
for _, n := range nodesNeedAppendChild {
|
||||
n.AppendChild(protyle.NewParagraph())
|
||||
n.AppendChild(parse.NewParagraph())
|
||||
}
|
||||
|
||||
// 折叠标题导出为模板后使用会出现内容重复 https://github.com/siyuan-note/siyuan/issues/4488
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
|
||||
"github.com/88250/lute"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/protyle"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
|
|
@ -59,7 +58,7 @@ func loadTree(localPath string, luteEngine *lute.Lute) (ret *parse.Tree, err err
|
|||
return
|
||||
}
|
||||
|
||||
ret, err = protyle.ParseJSONWithoutFix(luteEngine, data)
|
||||
ret, err = parse.ParseJSONWithoutFix(data, luteEngine.ParseOptions)
|
||||
if nil != err {
|
||||
logging.LogErrorf("parse json to tree [%s] failed: %s", localPath, err)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue