An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve Markdown import to parse audio/video tags https://github.com/siyuan-note/siyuan/issues/17985
Danielbe534e75b4b7
diff --git a/kernel/model/import.go b/kernel/model/import.goindex 91f6f01c5d..575ba20244 100644--- a/kernel/model/import.go+++ b/kernel/model/import.go@@ -1222,12 +1222,40 @@ func parseStdMd(markdown []byte) (ret *parse.Tree, yfmRootID, yfmTitle, yfmUpdatreturn}yfmRootID, yfmTitle, yfmUpdated = normalizeTree(ret)+ htmlBlock2Media(ret)htmlBlock2Inline(ret)parse.TextMarks2Inlines(ret) // 先将 TextMark 转换为 Inlines https://github.com/siyuan-note/siyuan/issues/13056parse.NestedInlines2FlattedSpansHybrid(ret, false)return}+// htmlBlock2Media 将导入标准 Markdown 时被识别为 HTML 块的 <audio>/<video> 还原为音频/视频块。+// 导入 Markdown 使用的是 NewStdLute,未启用 ProtyleWYSIWYG,故 lute 不会把 <audio>/<video> 解析为+// NodeAudio/NodeVideo,而是兜底为 NodeHTMLBlock,这里在解析后做一次修正。+// Improve Markdown import to parse audio/video tags https://github.com/siyuan-note/siyuan/issues/17985+func htmlBlock2Media(tree *parse.Tree) {+ ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {+ if !entering || ast.NodeHTMLBlock != n.Type {+ return ast.WalkContinue+ }++ tokens := bytes.TrimSpace(n.Tokens)+ tokens, _ = bytes.CutPrefix(tokens, []byte("<div>"))+ tokens, _ = bytes.CutSuffix(tokens, []byte("</div>"))+ tokens = bytes.TrimSpace(tokens)++ lower := bytes.ToLower(tokens)+ if bytes.HasPrefix(lower, []byte("<audio")) && bytes.HasSuffix(tokens, []byte(">")) {+ n.Type = ast.NodeAudio+ n.Tokens = tokens+ } else if bytes.HasPrefix(lower, []byte("<video")) && bytes.HasSuffix(tokens, []byte(">")) {+ n.Type = ast.NodeVideo+ n.Tokens = tokens+ }+ return ast.WalkContinue+ })+}+func processHTMLBlockSvgImg(n *ast.Node, assetDirPath string) {re := regexp.MustCompile(`(?i)<svg[^>]*>(.*?)</svg>`)matches := re.FindStringSubmatch(string(n.Tokens))