mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-07 21:22:34 +01:00
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
091ec8991d
commit
3d5c24519b
2 changed files with 8 additions and 14 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue