diff --git a/kernel/api/file.go b/kernel/api/file.go index 73db0c753..bfd15fe0d 100644 --- a/kernel/api/file.go +++ b/kernel/api/file.go @@ -485,7 +485,13 @@ func renameFile(c *gin.Context) { return } - srcPath := arg["path"].(string) + var srcPath string + if !util.ParseJsonArgs(arg, ret, + util.BindJsonArg("path", &srcPath, true, true), + ) { + return + } + srcAbsPath, err := util.GetAbsPathInWorkspace(srcPath) if err != nil { ret.Code = http.StatusForbidden @@ -532,7 +538,13 @@ func removeFile(c *gin.Context) { return } - filePath := arg["path"].(string) + var filePath string + if !util.ParseJsonArgs(arg, ret, + util.BindJsonArg("path", &filePath, true, true), + ) { + return + } + fileAbsPath, err := util.GetAbsPathInWorkspace(filePath) if err != nil { ret.Code = http.StatusForbidden diff --git a/kernel/sql/block.go b/kernel/sql/block.go index 15892f8be..b5631d043 100644 --- a/kernel/sql/block.go +++ b/kernel/sql/block.go @@ -162,6 +162,17 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi lastSpace := false ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus { if !entering { + if ast.NodeTable == n.Type { + caption := n.IALAttr("caption") + if "" != caption { + caption = html.UnescapeHTMLStr(caption) + if strings.Contains(caption, "caption-side:") && strings.Contains(caption, "bottom") { + caption = gulu.Str.SubStringBetween(caption, ">", "<") + buf.WriteByte(' ') + buf.WriteString(caption) + } + } + } return ast.WalkContinue } @@ -196,6 +207,17 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi } switch n.Type { + case ast.NodeTable: + caption := n.IALAttr("caption") + if "" != caption { + caption = html.UnescapeHTMLStr(caption) + if strings.Contains(caption, "caption-side:") && strings.Contains(caption, "bottom") { + return ast.WalkContinue + } + caption = gulu.Str.SubStringBetween(caption, ">", "<") + buf.WriteString(caption) + buf.WriteByte(' ') + } case ast.NodeTableCell: // 表格块写入数据库表时在单元格之间添加空格 https://github.com/siyuan-note/siyuan/issues/7654 if 0 < buf.Len() && ' ' != buf.Bytes()[buf.Len()-1] {