How would you do it? Markdown task to Things

Hello community,
I’m new on the automation scene and I’m looking for a solution to automate moving markdown tasks into Things on macOS.

I currently use iA Writer to chronicle my daily activities and sometimes I have tasks I need to complete. Things definitely offers superior task management feature to markdown text :slight_smile: I was thinking of using BTT to create a gesture that would move the text following the markdown task (- [ ]) into Things. But, I’m lost at where to start.

How would you set up this type of automation? Is it even possible?

Thanks for helping and taking time to guide this noob.

This was added semi-recently into the regular copy and paste in Things. If you’re willing this to not be a background task, that would be the easiest way.
There is also pretty good support via x-callback urls and AppleScript

Perhaps more complex, you can try building off of something in the GitHub tag things

I’ve attempted something similar in Python but got stuck and never completed it.

EDIT: Also found in this repo a service you could run or use as a starting point

Seems to just be a wrapper around this AppleScript
		set c to the clipboard as text
		set delimitedList to paragraphs of c
		set actionItemIdentifier to "- [ ] "
		set found to 0
		tell application "Things3"
			repeat with currentTodo in reverse of delimitedList
				if actionItemIdentifier is in currentTodo then
					set found to found + 1
					set theOffset to offset of actionItemIdentifier in currentTodo
					set theLength to the length of actionItemIdentifier
					set actionItem to characters (theOffset + theLength) thru -1 of currentTodo as string
					set newToDo to make new to do with properties {name:actionItem} at beginning of list "Inbox"
				end if
			end repeat
		end tell
		set result to "" & found & " task(s) found in clipboard"
		display notification result
	on error errMsg
		display dialog errMsg
	end try

I have a Hazel- and AppleScript-based automation for this. It picks up tasks from any new markdown file and puts them cleanly into my OmniFocus inbox, with links back to the note they came from (and the corresponding record in DEVONthink). The key is that I don’t need to act on the file to process the tasks—it just happens, about fifteen minutes after the note is modified.

(Once it runs it adds a captured tag to the file so that it won’t be scanned for tasks again.)

If folks are keen, I can try to clean up and document the code and post it here.

1 Like

@dustinknopoff thanks for looking up the Things AppleScript guide.

I’m going to take a look at it and see what I can figure out.

1 Like

@ryanjamurphy I’m very interested is seeing the AppleScript you wrote. Thanks for your willingness to share.

1 Like