mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-20 07:16:10 +01:00
🎨 The browser extension supports CSDN formula https://github.com/siyuan-note/siyuan/issues/5624
This commit is contained in:
parent
dfc8d39a68
commit
d3754bd630
5 changed files with 34 additions and 9 deletions
|
|
@ -121,10 +121,12 @@ func extensionCopy(c *gin.Context) {
|
|||
uploaded[oName] = "assets/" + fName
|
||||
}
|
||||
|
||||
luteEngine := util.NewStdLute()
|
||||
md, _ := model.HTML2Markdown(dom)
|
||||
md, withMath, _ := model.HTML2Markdown(dom)
|
||||
md = strings.TrimSpace(md)
|
||||
|
||||
luteEngine := util.NewStdLute()
|
||||
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 {
|
||||
|
|
@ -153,7 +155,8 @@ func extensionCopy(c *gin.Context) {
|
|||
|
||||
md, _ = lute.FormatNodeSync(tree.Root, luteEngine.ParseOptions, luteEngine.RenderOptions)
|
||||
ret.Data = map[string]interface{}{
|
||||
"md": md,
|
||||
"md": md,
|
||||
"withMath": withMath,
|
||||
}
|
||||
ret.Msg = model.Conf.Language(72)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -677,7 +677,13 @@ func createDocWithMd(c *gin.Context) {
|
|||
hPath = "/" + hPath
|
||||
}
|
||||
|
||||
id, err := model.CreateWithMarkdown(notebook, hPath, markdown, parentID, id)
|
||||
withMath := false
|
||||
withMathArg := arg["withMath"]
|
||||
if nil != withMathArg {
|
||||
withMath = withMathArg.(bool)
|
||||
}
|
||||
|
||||
id, err := model.CreateWithMarkdown(notebook, hPath, markdown, parentID, id, withMath)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
|
|
@ -57,13 +57,17 @@ func html2BlockDOM(c *gin.Context) {
|
|||
}
|
||||
|
||||
dom := arg["dom"].(string)
|
||||
markdown, err := model.HTML2Markdown(dom)
|
||||
markdown, withMath, err := model.HTML2Markdown(dom)
|
||||
if nil != err {
|
||||
ret.Data = "Failed to convert"
|
||||
return
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue