Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
24856a1c84
7 changed files with 24 additions and 12 deletions
8
app/stage/protyle/js/lute/lute.min.js
vendored
8
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -123,6 +123,7 @@ func extensionCopy(c *gin.Context) {
|
|||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
luteEngine.SetHTMLTag2TextMark(true)
|
||||
var md string
|
||||
var withMath bool
|
||||
if nil != form.Value["href"] {
|
||||
|
@ -175,7 +176,7 @@ func extensionCopy(c *gin.Context) {
|
|||
}
|
||||
|
||||
if "" == md {
|
||||
md, withMath, _ = model.HTML2Markdown(dom)
|
||||
md, withMath, _ = model.HTML2Markdown(dom, luteEngine)
|
||||
}
|
||||
|
||||
md = strings.TrimSpace(md)
|
||||
|
|
|
@ -57,13 +57,14 @@ func html2BlockDOM(c *gin.Context) {
|
|||
}
|
||||
|
||||
dom := arg["dom"].(string)
|
||||
markdown, withMath, err := model.HTML2Markdown(dom)
|
||||
luteEngine := util.NewLute()
|
||||
luteEngine.SetHTMLTag2TextMark(true)
|
||||
markdown, withMath, err := model.HTML2Markdown(dom, luteEngine)
|
||||
if err != nil {
|
||||
ret.Data = "Failed to convert"
|
||||
return
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
if withMath {
|
||||
luteEngine.SetInlineMath(true)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
|
||||
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
|
||||
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02
|
||||
github.com/88250/lute v1.7.7-0.20241028035735-91bbe8c1a561
|
||||
github.com/88250/lute v1.7.7-0.20241029093436-435765ab45e6
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
|
||||
|
|
|
@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02 h1:3e5+yobj655pTeKOYMbJrnc1mE51ZkbXIxquTYZuYCY=
|
||||
github.com/88250/gulu v1.2.3-0.20240612035750-c9cf5f7a4d02/go.mod h1:MUfzyfmbPrRDZLqxc7aPrVYveatTHRfoUa5TynPS0i8=
|
||||
github.com/88250/lute v1.7.7-0.20241028035735-91bbe8c1a561 h1:m0Akk/6lc7329W1QUWpy5Fph9W1poRYs1JSvCCxX/fQ=
|
||||
github.com/88250/lute v1.7.7-0.20241028035735-91bbe8c1a561/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
|
||||
github.com/88250/lute v1.7.7-0.20241029093436-435765ab45e6 h1:knKOryX3TDBe2Dro6kLTUdYNo81+8ixCfDocqVRwVhY=
|
||||
github.com/88250/lute v1.7.7-0.20241029093436-435765ab45e6/go.mod h1:VDAzL8b+oCh+e3NAlmwwLzC53ten0rZlS8NboB7ljtk=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c h1:Dl/8S9iLyPMTElnWIBxmjaLiWrkI5P4a21ivwAn5pU0=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20230401044135-c7369a99720c/go.mod h1:S5YT38L/GCjVjmB4PB84PymA1qfopjEhfhTNQilLpv4=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/88250/lute"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
|
@ -54,9 +55,8 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func HTML2Markdown(htmlStr string) (markdown string, withMath bool, err error) {
|
||||
func HTML2Markdown(htmlStr string, luteEngine *lute.Lute) (markdown string, withMath bool, err error) {
|
||||
assetDirPath := filepath.Join(util.DataDir, "assets")
|
||||
luteEngine := util.NewLute()
|
||||
tree := luteEngine.HTML2Tree(htmlStr)
|
||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering {
|
||||
|
|
|
@ -509,6 +509,16 @@ func RenderTemplateCol(ial map[string]string, rowValues []*av.KeyValues, tplCont
|
|||
}
|
||||
dataModel[rowValue.Key.Name] = contents
|
||||
}
|
||||
} else if av.KeyTypeBlock == v.Type {
|
||||
dataModel[rowValue.Key.Name+"_created"] = time.Now()
|
||||
if nil != v.Block {
|
||||
dataModel["entryCreated"] = time.UnixMilli(v.Block.Created)
|
||||
}
|
||||
dataModel["entryUpdated"] = time.Now()
|
||||
if nil != v.Block {
|
||||
dataModel["entryUpdated"] = time.UnixMilli(v.Block.Updated)
|
||||
}
|
||||
dataModel[rowValue.Key.Name] = v.String(true)
|
||||
} else {
|
||||
dataModel[rowValue.Key.Name] = v.String(true)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue