Find Markdown files with checkboxes "- [ ] "

I imported a lot of markdown files which include a huge number of tasks, specified following Github markdown checkbox definition, i.e.

- Do this #atHome

I thought those boxes are “supported” by DEVONthink, but I cannot construct a search which would find me the respective files with those tasks.

I read the documentation, and I tried

  • "- "
    /- [ ]/

and some other constructions.

What is the correct way to define a search/smart search to find all the files with tasks?

Thanks!

AFAIK, DT does not find _any _ markup. There might be a hidden preference to change that, for which you should check the relevant section of the manual.

Only alphanumeric characters are indexed & searchable, therefore that’s not possible. The only workaround would be to use a script:

tell application id "DNtp"
	set search results of viewer window 1 to (contents of current database whose type is markdown and plain text contains "-[]")
end tell

However, depending on the size & number of Markdown documents in the database this might be slow.

1 Like

Thanks Christian, works like a charm. Just as a hint for others coming to this thread later, the correct syntax ist

contains “-

with spaces between the brackets and before the first bracket.

2 Likes

Here’s an extended version adding a dialog to enter the desired search string:

tell application id "DNtp"
	try
		repeat
			set search_string to display name editor "Markdown Search" info "Enter text to find:"
			if search_string is not "" then exit repeat
		end repeat
		
		set search results of viewer window 1 to (contents of current database whose type is markdown and plain text contains search_string)
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
	end try
end tell
3 Likes

This is extremely useful for me: many thanks!

Stephen

Where do you put this script in DT please?

To be honest I can’t now recall why I found this script useful at the time. :grinning: I suspect I used part of it in another script I wrote.

However, in answer to your question, in the DEVONthink menu bar click on the script symbol before Help:

then choose Open Scripts Folder and select the appropriate folder (or create a new one) for the script.

Stephen