This script translates a DEVONthink query into regex, searches in selected records and creates a Markdown record with search hits plus context.
It makes it possible to view search hits of one or more selected records at once.
Usage
-
Do a toolbar search in a main window
-
Select some result records
-
Run script
Result
-
A Markdown record with search hits plus context
-
Click a search hit to open the record with the search hit highlighted.
Context length
-
Context length can be set in property
maxContextCharacters
. -
Search hits are joined if their ranges plus context overlaps.
Result with maxContextCharacters
set to 100:
Result with maxContextCharacters
set to 150:
Link behaviour
- If property
revealLinkedRecord
is set totrue
then clicking a record link reveals the record in the main window.
CSS:
If you use a CSS file and want to change the styling of existing script output records in the future you can add something like
searchResultHit {
color: #1e1e1e;
background-color:#ffa718;
}
a.recordLink {
color: inherit;
background-color: inherit;
text-decoration: none;
}
to your file and then set property theCSS
to ""
.
Thanks @chrillek and @BLUEFROG!
Debugging
This script is quite experimental. In its current state it does not attempt to translate all possible DEVONthink queries.
If it fails âŠ
Note:
If clicking a search hit doesnât highlight the search hit and therefore doesnât open the result record on the right page then the search hit plus context probably exceeds the page end. In this case itâs not possible to highlight it. Please make sure to check whether thatâs the case before you post a debugging request.
⊠to translate a query into regex just post the first part of the resulting Markdown recordâs source and Iâll see whether itâs possible to add support for this kind of query.
Caution
Regex-searching is an expensive operation. This script should not be used with simply selecting all result records. If possible select only those records youâre interested in.