Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Fix https://github.com/siyuan-note/siyuan/issues/17138

Daniel091ec8991d53
diff --git a/kernel/api/lute.go b/kernel/api/lute.go
index 55752f4076..6381bb4853 100644
--- a/kernel/api/lute.go
+++ b/kernel/api/lute.go
@@ -80,18 +80,20 @@ func html2BlockDOM(c *gin.Context) {
luteEngine := util.NewLute()
luteEngine.SetHTMLTag2TextMark(true)
luteEngine.SetHTML2MarkdownAttrs([]string{"alias", "memo", "bookmark", "custom-*"})
- markdown, withMath, err := model.HTML2Markdown(dom, luteEngine)
- if err != nil {
+ tree, _ := model.HTML2Tree(dom, luteEngine)
+ if nil == tree {
+ md, withMath, _ := model.HTML2Markdown(dom, luteEngine)
+ if withMath {
+ luteEngine.SetInlineMath(true)
+ }
+ tree = parse.Parse("", []byte(md), luteEngine.ParseOptions)
+ }
+ if nil == tree {
ret.Data = "Failed to convert"
return
}
- if withMath {
- luteEngine.SetInlineMath(true)
- }
-
var unlinks []*ast.Node
- tree := parse.Parse("", []byte(markdown), luteEngine.ParseOptions)
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
@@ -177,7 +179,7 @@ func html2BlockDOM(c *gin.Context) {
name = name[0 : len(name)-len(ext)]
name = name + "-" + ast.NewNodeID() + ext
targetPath := filepath.Join(util.DataDir, "assets", name)
- if err = filelock.Copy(localPath, targetPath); err != nil {
+ if err := filelock.Copy(localPath, targetPath); err != nil {
logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", localPath, targetPath, err)
return ast.WalkStop
}