Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-09-19 10:05:52 +08:00
commit 836682bd27
8 changed files with 33 additions and 12 deletions

File diff suppressed because one or more lines are too long

View file

@ -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.20220919015919-e05391a106b3
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

View file

@ -21,6 +21,10 @@ 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/lute v1.7.5-0.20220919015919-e05391a106b3 h1:F78DnfTxvC2ugvvt174mtampLS71w6+tqAYGa01DSVw=
github.com/88250/lute v1.7.5-0.20220919015919-e05391a106b3/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=

View file

@ -685,7 +685,8 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
// 修改以下代码时需要同时修改 database 构造行级元素实现,增加必要的类型
if !entering || (ast.NodeLinkDest != n.Type && ast.NodeHTMLBlock != n.Type && ast.NodeInlineHTML != n.Type &&
ast.NodeIFrame != n.Type && ast.NodeWidget != n.Type && ast.NodeAudio != n.Type && ast.NodeVideo != n.Type) {
ast.NodeIFrame != n.Type && ast.NodeWidget != n.Type && ast.NodeAudio != n.Type && ast.NodeVideo != n.Type &&
!n.IsTextMarkType("a")) {
return ast.WalkContinue
}
@ -696,6 +697,13 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
dest := strings.TrimSpace(string(n.Tokens))
ret = append(ret, dest)
} else if n.IsTextMarkType("a") {
if !isRelativePath(gulu.Str.ToBytes(n.TextMarkAHref)) {
return ast.WalkContinue
}
dest := strings.TrimSpace(n.TextMarkAHref)
ret = append(ret, dest)
} else {
if ast.NodeWidget == n.Type {
dataAssets := n.IALAttr("custom-data-assets")

View file

@ -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
}

View file

@ -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) {

View file

@ -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(),

View file

@ -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 ""