🎨 数据库中表 blocks
的 markdown
字段使用 Markdown 标记符 Fix https://github.com/siyuan-note/insider/issues/1053
This commit is contained in:
parent
371062efdb
commit
a383f8de68
7 changed files with 21 additions and 10 deletions
4
app/stage/protyle/js/lute/lute.min.js
vendored
4
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@ require (
|
|||
github.com/88250/css v0.1.2
|
||||
github.com/88250/flock v0.8.2
|
||||
github.com/88250/gulu v1.2.3-0.20220916075322-eb117059d70a
|
||||
github.com/88250/lute v1.7.5-0.20220918140805-18adc927144a
|
||||
github.com/88250/lute v1.7.5-0.20220919014341-2efb181e3736
|
||||
github.com/88250/pdfcpu v0.3.13
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ConradIrwin/font v0.0.0-20210318200717-ce8d41cc0732
|
||||
|
|
|
@ -21,6 +21,8 @@ github.com/88250/gulu v1.2.3-0.20220916075322-eb117059d70a h1:qQdnk8clbgA+MXtf5b
|
|||
github.com/88250/gulu v1.2.3-0.20220916075322-eb117059d70a/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
|
||||
github.com/88250/lute v1.7.5-0.20220918140805-18adc927144a h1:9nyjAkdNKIjQCJmNbtcqdMhG4bUHbf8QtUNGtFs/nJc=
|
||||
github.com/88250/lute v1.7.5-0.20220918140805-18adc927144a/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/lute v1.7.5-0.20220919014341-2efb181e3736 h1:uxHR5azRT/mNRiQzq/THSsES0MeJ3KDfxfKDN2zh9aI=
|
||||
github.com/88250/lute v1.7.5-0.20220919014341-2efb181e3736/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
|
||||
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=
|
||||
github.com/88250/pdfcpu v0.3.13/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
@ -113,7 +113,7 @@ func GetBlockKramdown(id string) (ret string) {
|
|||
addBlockIALNodes(tree, false)
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
luteEngine := NewLute()
|
||||
ret, _ = lute.FormatNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
ret = treenode.ExportNodeStdMd(node, luteEngine)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -601,7 +601,7 @@ func CopyStdMarkdown(id string) string {
|
|||
// 订阅用户使用云端图床服务
|
||||
luteEngine.RenderOptions.LinkBase = "https://assets.b3logfile.com/siyuan/" + Conf.User.UserId + "/"
|
||||
}
|
||||
return treenode.FormatNode(tree.Root, luteEngine)
|
||||
return treenode.ExportNodeStdMd(tree.Root, luteEngine)
|
||||
}
|
||||
|
||||
func ExportMarkdown(id string) (name, zipPath string) {
|
||||
|
|
|
@ -307,7 +307,7 @@ func refsFromTree(tree *parse.Tree) (refs []*Ref, fileAnnotationRefs []*FileAnno
|
|||
}
|
||||
|
||||
func buildRef(tree *parse.Tree, refNode *ast.Node) *Ref {
|
||||
markdown := treenode.FormatNode(refNode, luteEngine)
|
||||
markdown := treenode.ExportNodeStdMd(refNode, luteEngine)
|
||||
defBlockID, text, _ := treenode.GetBlockRef(refNode)
|
||||
var defBlockParentID, defBlockRootID, defBlockPath string
|
||||
defBlock := treenode.GetBlockTree(defBlockID)
|
||||
|
@ -525,7 +525,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
|||
switch n.Type {
|
||||
case ast.NodeLinkText:
|
||||
text := n.Text()
|
||||
markdown := treenode.FormatNode(n.Parent, luteEngine)
|
||||
markdown := treenode.ExportNodeStdMd(n.Parent, luteEngine)
|
||||
parentBlock := treenode.ParentBlock(n)
|
||||
span := &Span{
|
||||
ID: ast.NewNodeID(),
|
||||
|
@ -556,7 +556,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
|||
typ = typ + " " + n.TextMarkType
|
||||
}
|
||||
|
||||
markdown := treenode.FormatNode(n, luteEngine)
|
||||
markdown := treenode.ExportNodeStdMd(n, luteEngine)
|
||||
parentBlock := treenode.ParentBlock(n)
|
||||
span := &Span{
|
||||
ID: ast.NewNodeID(),
|
||||
|
@ -574,7 +574,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
|||
return
|
||||
case ast.NodeLinkDest:
|
||||
text := n.TokensStr()
|
||||
markdown := treenode.FormatNode(n.Parent, luteEngine)
|
||||
markdown := treenode.ExportNodeStdMd(n.Parent, luteEngine)
|
||||
parentBlock := treenode.ParentBlock(n)
|
||||
span := &Span{
|
||||
ID: ast.NewNodeID(),
|
||||
|
|
|
@ -168,7 +168,7 @@ func processNestedNode(n *ast.Node, tag string, tags *[]string, unlinks *[]*ast.
|
|||
}
|
||||
|
||||
func NodeStaticMdContent(node *ast.Node, luteEngine *lute.Lute) (md, content string) {
|
||||
md = FormatNode(node, luteEngine)
|
||||
md = ExportNodeStdMd(node, luteEngine)
|
||||
content = NodeStaticContent(node)
|
||||
return
|
||||
}
|
||||
|
@ -182,6 +182,15 @@ func FormatNode(node *ast.Node, luteEngine *lute.Lute) string {
|
|||
return markdown
|
||||
}
|
||||
|
||||
func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {
|
||||
markdown, err := lute.ProtyleExportMdNodeSync(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
if nil != err {
|
||||
root := TreeRoot(node)
|
||||
logging.LogFatalf("export markdown for node [%s] in tree [%s] failed: %s", node.ID, root.ID, err)
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func NodeStaticContent(node *ast.Node) string {
|
||||
if nil == node {
|
||||
return ""
|
||||
|
|
Loading…
Add table
Reference in a new issue