mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🐛 Unable to search audio, video blocks by asset path https://github.com/siyuan-note/siyuan/issues/10468
This commit is contained in:
parent
1a5355ce27
commit
8d9eafbfd8
3 changed files with 39 additions and 28 deletions
|
@ -283,6 +283,9 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
buf.WriteByte(lex.ItemBackslash)
|
||||
case ast.NodeBackslashContent:
|
||||
buf.Write(n.Tokens)
|
||||
case ast.NodeAudio, ast.NodeVideo:
|
||||
buf.WriteString(GetNodeSrcTokens(n))
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
lastSpace = false
|
||||
return ast.WalkContinue
|
||||
|
@ -293,6 +296,34 @@ func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATi
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
func GetNodeSrcTokens(n *ast.Node) (ret string) {
|
||||
if index := bytes.Index(n.Tokens, []byte("src=\"")); 0 < index {
|
||||
src := n.Tokens[index+len("src=\""):]
|
||||
if index = bytes.Index(src, []byte("\"")); 0 < index {
|
||||
src = src[:bytes.Index(src, []byte("\""))]
|
||||
if !IsRelativePath(src) {
|
||||
return
|
||||
}
|
||||
|
||||
ret = strings.TrimSpace(string(src))
|
||||
return
|
||||
}
|
||||
|
||||
logging.LogWarnf("src is missing the closing double quote in tree [%s] ", n.Box+n.Path)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func IsRelativePath(dest []byte) bool {
|
||||
if 1 > len(dest) {
|
||||
return false
|
||||
}
|
||||
if '/' == dest[0] {
|
||||
return false
|
||||
}
|
||||
return !bytes.Contains(dest, []byte(":"))
|
||||
}
|
||||
|
||||
func FirstLeafBlock(node *ast.Node) (ret *ast.Node) {
|
||||
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||
if !entering || n.IsMarker() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue