🎨 OCR no longer blocks document loading https://github.com/siyuan-note/siyuan/issues/9230

This commit is contained in:
Daniel 2023-12-07 20:40:16 +08:00
parent b31765d0ab
commit 283917a9a8
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
8 changed files with 123 additions and 11 deletions

View file

@ -137,6 +137,32 @@ func ExportNodeStdMd(node *ast.Node, luteEngine *lute.Lute) string {
return markdown
}
func IsNodeOCRed(node *ast.Node) (ret bool) {
ret = true
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
if ast.NodeImage == n.Type {
linkDest := n.ChildByType(ast.NodeLinkDest)
if nil != linkDest {
linkDestStr := linkDest.TokensStr()
if !cache.ExistAsset(linkDestStr) {
return ast.WalkContinue
}
if !util.ExistsAssetText(linkDestStr) {
ret = false
return ast.WalkStop
}
}
}
return ast.WalkContinue
})
return
}
func NodeStaticContent(node *ast.Node, excludeTypes []string, includeTextMarkATitleURL, includeAssetPath bool) string {
if nil == node {
return ""