An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
Fix the index task of the embedded block (#11154)
Yingyi / 颖逸e2c14eb11fe3
diff --git a/kernel/model/index.go b/kernel/model/index.goindex 455e2ff4ad..78d29376f9 100644--- a/kernel/model/index.go+++ b/kernel/model/index.go@@ -30,6 +30,7 @@ import ("github.com/88250/go-humanize""github.com/88250/gulu""github.com/88250/lute/ast"+ "github.com/88250/lute/editor""github.com/88250/lute/html""github.com/88250/lute/parse""github.com/panjf2000/ants/v2"@@ -289,14 +290,22 @@ func IndexEmbedBlockJob() {func autoIndexEmbedBlock(embedBlocks []*sql.Block) {for i, embedBlock := range embedBlocks {- md := strings.TrimSpace(embedBlock.Markdown)- if strings.Contains(md, "//js") {+ markdown := strings.TrimSpace(embedBlock.Markdown)+ markdown = strings.TrimPrefix(markdown, "{{")+ stmt := strings.TrimSuffix(markdown, "}}")++ // 嵌入块的 Markdown 内容需要反转义+ stmt = html.UnescapeString(stmt)+ stmt = strings.ReplaceAll(stmt, editor.IALValEscNewLine, "\n")++ // 需要移除首尾的空白字符以判断是否具有 //!js 标记+ stmt = strings.TrimSpace(stmt)+ if strings.HasPrefix(stmt, "//!js") {+ // https://github.com/siyuan-note/siyuan/issues/9648// js 嵌入块不支持自动索引,由前端主动调用 /api/search/updateEmbedBlock 接口更新内容 https://github.com/siyuan-note/siyuan/issues/9736continue}- stmt := strings.TrimPrefix(md, "{{")- stmt = strings.TrimSuffix(stmt, "}}")if !strings.Contains(strings.ToLower(stmt), "select") {continue}