Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sends the input text to Fantastical, converting TaskPaper @due(YYYY-MM-DD) tags to plain text for Fantastical to parse as a Reminder. Designed for use with Drafts and Pythonista.
# tp2fantastical
#
# by Derick Fay, 2014-04-06
#
# an adaptation of the Selection to Fantastical Editorial workflow
# (http://editorial-app.appspot.com/workflow/6172238982152192/Y3VYajI3Hzc )
# for use with Drafts and Pythonista (both required)
#
# works on iPhone and iPad
# I have also written an equivalent script for TaskPaper for the Mac
# available at http://www.hogbaysoftware.com/wiki/ParseClipboardInFantastical
#
# installation:
# 1) copy this script into Pythonista and name it tp2fantastical
# 2) create a Drafts URL Action with the following URL:
# pythonista://tp2fantastical?action=run&argv=[[draft]]
#
import sys
import webbrowser
import urllib
i = sys.argv[1]
#i = "Test item @due(2014-05-14)"
if '@due(' in i:
theEnd=""
theStart=i.split('@due(')[0]
theDate=i.split('@due(')[1][0:10]
theEnd=i[(i.index('@due(')+16):]
i = theStart + " due " + theDate + theEnd
webbrowser.open("fantastical2://parse?sentence=" + urllib.quote(i))
Owner

2014-04-21: corrected Drafts action

Owner

added link to Mac version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment