From 9f6d08ac01a7ff50b22231b44416cbd22697f0e3 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 15 Aug 2023 09:34:58 +0800 Subject: [PATCH 1/2] :sparkles: Support for searching asset content https://github.com/siyuan-note/siyuan/issues/8874 --- kernel/model/asset_content.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/model/asset_content.go b/kernel/model/asset_content.go index 1863962e2..6a1e5cd55 100644 --- a/kernel/model/asset_content.go +++ b/kernel/model/asset_content.go @@ -28,6 +28,7 @@ import ( "code.sajari.com/docconv" "github.com/88250/gulu" "github.com/88250/lute/ast" + "github.com/dustin/go-humanize" "github.com/siyuan-note/eventbus" "github.com/siyuan-note/filelock" "github.com/siyuan-note/logging" @@ -43,6 +44,7 @@ type AssetContent struct { Ext string `json:"ext"` Path string `json:"path"` Size int64 `json:"size"` + HSize string `json:"hSize"` Updated int64 `json:"updated"` Content string `json:"content"` } @@ -219,6 +221,7 @@ func fromSQLAssetContent(assetContent *sql.AssetContent, beforeLen int) *AssetCo Ext: assetContent.Ext, Path: assetContent.Path, Size: assetContent.Size, + HSize: humanize.Bytes(uint64(assetContent.Size)), Updated: assetContent.Updated, Content: assetContent.Content, } From 68be7bdfe407ac08be4f3dd38eb22d65aa8b3387 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 15 Aug 2023 10:07:28 +0800 Subject: [PATCH 2/2] :art: Improve node parsing --- kernel/filesys/json_parser.go | 3 +++ kernel/sql/database.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/kernel/filesys/json_parser.go b/kernel/filesys/json_parser.go index 81cbe6b30..bf7a81753 100644 --- a/kernel/filesys/json_parser.go +++ b/kernel/filesys/json_parser.go @@ -232,6 +232,9 @@ func fixLegacyData(tip, node *ast.Node, idMap *map[string]bool, needFix, needMig // 建立索引时无法解析 `v2.2.0-` 版本的块引用 https://github.com/siyuan-note/siyuan/issues/6889 // 早先的迁移程序有缺陷,漏迁移了块引用节点,这里检测到块引用节点后标识需要迁移 *needMigrate2Spec1 = true + case ast.NodeInlineHTML: + *needFix = true + node.Type = ast.NodeHTMLBlock } for _, kv := range node.KramdownIAL { diff --git a/kernel/sql/database.go b/kernel/sql/database.go index afec892fa..9227cf454 100644 --- a/kernel/sql/database.go +++ b/kernel/sql/database.go @@ -689,6 +689,16 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) ( attributes = append(attributes, attrs...) } + if ast.NodeInlineHTML == n.Type { + // 没有行级 HTML,只有块级 HTML,这里转换为块 + b, attrs := buildBlockFromNode(n, tree) + b.Type = ast.NodeHTMLBlock.String() + blocks = append(blocks, b) + attributes = append(attributes, attrs...) + walkStatus = ast.WalkContinue + return + } + if 1 > len(nodes) { walkStatus = ast.WalkContinue return