Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-03-06 08:44:31 +08:00
parent 091ec8991d
commit 3d5c24519b
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 8 additions and 14 deletions

View file

@ -224,13 +224,6 @@ func extensionCopy(c *gin.Context) {
})
tree, withMath = 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)
}
} else {
tree = parse.Parse("", []byte(md), luteEngine.ParseOptions)
}

View file

@ -23,6 +23,7 @@ import (
"strings"
"github.com/88250/gulu"
"github.com/88250/lute"
"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
@ -81,13 +82,6 @@ func html2BlockDOM(c *gin.Context) {
luteEngine.SetHTMLTag2TextMark(true)
luteEngine.SetHTML2MarkdownAttrs([]string{"alias", "memo", "bookmark", "custom-*"})
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
@ -191,6 +185,13 @@ func html2BlockDOM(c *gin.Context) {
parse.TextMarks2Inlines(tree) // 先将 TextMark 转换为 Inlines https://github.com/siyuan-note/siyuan/issues/13056
parse.NestedInlines2FlattedSpansHybrid(tree, false)
md, err := lute.FormatNodeSync(tree.Root, luteEngine.ParseOptions, luteEngine.RenderOptions)
if nil != err {
ret.Data = "Failed to convert"
return
}
tree = parse.Parse("", []byte(md), luteEngine.ParseOptions)
renderer := render.NewProtyleRenderer(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)
output := renderer.Render()
ret.Data = gulu.Str.FromBytes(output)