|
@@ -634,17 +634,15 @@ func UnusedAssets() (ret []string) {
|
|
|
|
|
|
for _, dest := range linkDestFilePaths {
|
|
|
linkDestMap[dest] = true
|
|
|
+
|
|
|
+ if strings.HasSuffix(dest, ".pdf") {
|
|
|
+ linkDestMap[dest+".sya"] = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var toRemoves []string
|
|
|
for asset, _ := range assetsPathMap {
|
|
|
- if strings.HasSuffix(asset, ".sya") {
|
|
|
- // 排除文件注解和对应文件
|
|
|
- toRemoves = append(toRemoves, asset, strings.TrimSuffix(asset, ".sya"))
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
if strings.HasSuffix(asset, "ocr-texts.json") {
|
|
|
// 排除 OCR 结果文本
|
|
|
toRemoves = append(toRemoves, asset)
|
|
@@ -656,8 +654,8 @@ func UnusedAssets() (ret []string) {
|
|
|
}
|
|
|
|
|
|
dataAssetsAbsPath := util.GetDataAssetsAbsPath()
|
|
|
- for _, assetAbsPath := range assetsPathMap {
|
|
|
- if _, ok := linkDestMap[assetAbsPath]; ok {
|
|
|
+ for dest, assetAbsPath := range assetsPathMap {
|
|
|
+ if _, ok := linkDestMap[dest]; ok {
|
|
|
continue
|
|
|
}
|
|
|
|
|
@@ -704,7 +702,7 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
|
|
|
// 修改以下代码时需要同时修改 database 构造行级元素实现,增加必要的类型
|
|
|
if !entering || (ast.NodeLinkDest != n.Type && ast.NodeHTMLBlock != n.Type && ast.NodeInlineHTML != n.Type &&
|
|
|
ast.NodeIFrame != n.Type && ast.NodeWidget != n.Type && ast.NodeAudio != n.Type && ast.NodeVideo != n.Type &&
|
|
|
- !n.IsTextMarkType("a")) {
|
|
|
+ !n.IsTextMarkType("a") && !n.IsTextMarkType("file-annotation-ref")) {
|
|
|
return ast.WalkContinue
|
|
|
}
|
|
|
|
|
@@ -722,6 +720,14 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
|
|
|
|
|
|
dest := strings.TrimSpace(n.TextMarkAHref)
|
|
|
ret = append(ret, dest)
|
|
|
+ } else if n.IsTextMarkType("file-annotation-ref") {
|
|
|
+ if !isRelativePath(gulu.Str.ToBytes(n.TextMarkFileAnnotationRefID)) {
|
|
|
+ return ast.WalkContinue
|
|
|
+ }
|
|
|
+
|
|
|
+ dest := n.TextMarkFileAnnotationRefID[:strings.LastIndexByte(n.TextMarkFileAnnotationRefID, '/')]
|
|
|
+ dest = strings.TrimSpace(dest)
|
|
|
+ ret = append(ret, dest)
|
|
|
} else {
|
|
|
if ast.NodeWidget == n.Type {
|
|
|
dataAssets := n.IALAttr("custom-data-assets")
|
|
@@ -752,6 +758,7 @@ func assetsLinkDestsInTree(tree *parse.Tree) (ret []string) {
|
|
|
}
|
|
|
return ast.WalkContinue
|
|
|
})
|
|
|
+ ret = gulu.Str.RemoveDuplicatedElem(ret)
|
|
|
return
|
|
|
}
|
|
|
|