mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-02 06:48:49 +01:00
🎨 Improve HTML clipping https://github.com/siyuan-note/siyuan/issues/13125#issuecomment-2475461284
This commit is contained in:
parent
ab147598e1
commit
e408546be5
3 changed files with 40 additions and 22 deletions
|
|
@ -123,7 +123,12 @@ func extensionCopy(c *gin.Context) {
|
|||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
luteEngine.SetHTMLTag2TextMark(true)
|
||||
luteEngine.SetSup(true)
|
||||
luteEngine.SetSub(true)
|
||||
luteEngine.SetMark(true)
|
||||
luteEngine.SetGFMStrikethrough(true)
|
||||
luteEngine.SetInlineAsterisk(true)
|
||||
luteEngine.SetInlineUnderscore(true)
|
||||
var md string
|
||||
var withMath bool
|
||||
if nil != form.Value["href"] {
|
||||
|
|
@ -175,16 +180,19 @@ func extensionCopy(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
var tree *parse.Tree
|
||||
if "" == md {
|
||||
md, withMath, _ = model.HTML2Markdown(dom, luteEngine)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
md = strings.TrimSpace(md)
|
||||
if withMath {
|
||||
luteEngine.SetInlineMath(true)
|
||||
}
|
||||
var unlinks []*ast.Node
|
||||
tree := parse.Parse("", []byte(md), luteEngine.ParseOptions)
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
return ast.WalkContinue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue