Filter by color of highlighted pdf quotations

Hello everybody,

I wondered if it is possible to filter Pdf-quotations (marked quotations in the pdf) by color. I would find this really usefull, because by scientific work, you would not have to double categorize the quotations, but just by color you could extract them to another page. For example I mark every definition in green, and every opinion in yellow and so far. If I finish a text, I have a colorful sample of Quotes which then I had to recategorize by myself - or in the working process everytime adding #definition. It would be so easy, if I could filter them by color.

If you have any hint for me how to do - or any work around, Id be very thankful!

My best regards,

Chris

I’ve had this in my own references for quite some time. I don’t really do PDF highlighting so never tried to use it.
But I hope this is what you are looking for.

Filter pdf highlights
this query will pull all highlighted pdf with green color. you can add extra clause for narrow result.

{:query [:find (pull ?b [*])
         :where
         (property ?b :hl-color "green")
        ]
}
1 Like

Thank you so much! i’m still trying to get more familiar with the advanced query syntax. trying to add a page reference here below but it’s not working could you give advice? many thanks in advance

#+BEGIN_QUERY
{:query [:find (pull ?b [*])
         :where
         [?page :block/name "test"]
         (property ?b :hl-color "yellow")
        ]
}
#+END_QUERY

It’s because ?page and ?b are now not linked together in anyway.
We need to specify that block ?b is on page ?page or alternatively references it. Depends on what you want with the page.

Block is on page:

#+BEGIN_QUERY
{:query [:find (pull ?b [*])
         :where
         [?page :block/name "test"]
         [?b :block/page ?page]
         (property ?b :hl-color "yellow")
        ]
}
#+END_QUERY

Block references page:

#+BEGIN_QUERY
{:query [:find (pull ?b [*])
         :where
         [?page :block/name "test"]
         [?b :block/refs ?page]
         (property ?b :hl-color "yellow")
        ]
}
#+END_QUERY

Either of them:

#+BEGIN_QUERY
{:query [:find (pull ?b [*])
         :where
         [?page :block/name "test"]
         (or
           [?b :block/page ?page]
           [?b :block/refs ?page]
         )
         (property ?b :hl-color "yellow")
        ]
}
#+END_QUERY
1 Like

This is great! Thank you so much for the answer plus the explanation. You’re so helpful!! :star_struck::fire::pray:

2 Likes

Simplified query:

To get all the green highlights from every PDF:

{{query (AND (property :ls-type “annotation”) (property :hl-color “green”))}}

To get all the green highlihts from a given PDF:

{{query (AND (property :ls-type “annotation”) (property :hl-color “green”) [[hls__pdfname_with_number]])}}

Where [[hls__pdfname_with_number]] is the name of the file where the annotations are stored.