Hi, sometimes when I edit my page, I would sometimes remove a block or two, which might cause some blocks’ references invalid.
I am wondering if there is some way to retrieve all invalid references. Thanks!
Agree this would be a nice feature. I have a python script to find invalid block references for now. It works for me and might be of some use to others
Hi, inspired by Advanced queries for Logseq - gist.github.com/, I found this query very helpful
#+BEGIN_QUERY
{:title "Broken References"
:query [:find (pull ?b [*])
:where
[?b :block/refs ?t]
[(missing? $ ?t :block/name)]
[(missing? $ ?t :block/content)]]
}
#+END_QUERY
I didn’t check it further so I cannot say for sure that all broken references are catched by the query.
1 Like
Thanks for sharing this @vou. Looks like the query is updated now.
Below is the updated query
#+BEGIN_QUERY
{:title "Broken References"
:query [:find (pull ?b [*])
:in $ ?matcher
:where
[(re-pattern ?matcher) ?regex]
[?b :block/content ?c]
[(re-find ?regex ?c)]
[(missing? $ ?b :block/refs)]]
:inputs [ "\\([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\)"]
}
#+END_QUERY
Also I had a similar question posted here - not for broken references, but for invalid references: