Skip to content

Instantly share code, notes, and snippets.

@hiilppp hiilppp/
Created Dec 10, 2013

What would you like to do?
Python script to manipulate text in Pythonista in the following manner and send the result (back) to Drafts: Sort lines, remove blank and duplicate lines, and prepend a hyphen to lines which don't start with one.
# To call script from Drafts, use the follwing URL as URL Action:
# <pythonista://[[draft]]>
import os
import re
import sys
import urllib
import webbrowser
a = re.sub(r"(?m)^[*-] ", "", sys.argv[1])
a = set(a.split("\n"))
a = "".join([l + "\n" for l in a])
a = os.linesep.join([s for s in a.split("\n") if s])
a = a.split("\n")
a = "\n".join(a)
a = re.sub(r"(?m)^", "- ", a)"drafts://x-callback-url/create?text=" + urllib.quote(a))

This comment has been minimized.

Copy link
Owner Author

hiilppp commented Apr 22, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.