mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
145641cd06
commit
bb0ebefb1d
2 changed files with 58 additions and 4 deletions
|
|
@ -514,6 +514,40 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
|
|||
IAL: treenode.IALStr(n),
|
||||
}
|
||||
spans = append(spans, span)
|
||||
|
||||
if n.IsTextMarkType("a") {
|
||||
dest := n.TextMarkAHref
|
||||
if util.IsAssetLinkDest([]byte(dest)) {
|
||||
var title string
|
||||
if titleNode := n.ChildByType(ast.NodeLinkTitle); nil != titleNode {
|
||||
title = gulu.Str.FromBytes(titleNode.Tokens)
|
||||
}
|
||||
|
||||
var hash string
|
||||
var hashErr error
|
||||
if lp := assetLocalPath(dest, boxLocalPath, docDirLocalPath); "" != lp {
|
||||
if !gulu.File.IsDir(lp) {
|
||||
hash, hashErr = util.GetEtag(lp)
|
||||
if nil != hashErr {
|
||||
logging.LogErrorf("calc asset [%s] hash failed: %s", lp, hashErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
name, _ := util.LastID(dest)
|
||||
asset := &Asset{
|
||||
ID: ast.NewNodeID(),
|
||||
BlockID: parentBlock.ID,
|
||||
RootID: rootID,
|
||||
Box: boxID,
|
||||
DocPath: p,
|
||||
Path: dest,
|
||||
Name: name,
|
||||
Title: title,
|
||||
Hash: hash,
|
||||
}
|
||||
assets = append(assets, asset)
|
||||
}
|
||||
}
|
||||
walkStatus = ast.WalkSkipChildren
|
||||
return
|
||||
case ast.NodeDocument:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue