Skip to content

Instantly share code, notes, and snippets.

@Morse-Code
Created November 9, 2012 13:53
Show Gist options
  • Save Morse-Code/4045748 to your computer and use it in GitHub Desktop.
Save Morse-Code/4045748 to your computer and use it in GitHub Desktop.
marky
# Here is a Bookmarklet for running the script using the current page's URL
# as input: javascript:(function()%7Bif(document.location.href.indexOf('http')===0)document.location.href='pythonista://marky?action=run&argv='+document.location.href;%7D)();
import clipboard
import urllib2
import webbrowser
def markdownify(clipstring):
marky = 'http://heckyesmarkdown.com/go/?u='
queryString = marky + clipString
reqMD = urllib2.Request(queryString)
openMD = urllib2.urlopen(reqMD)
content = (openMD.read().decode('utf-8'))
clipboard.set(content)
webbrowser.open(queryString)
if __name__ == '__main__':
if len(sys.argv) == 2:
clipString = sys.argv[1]
else:
clipString = clipboard.get()
markdownify(clipString)
@Morse-Code
Copy link
Author

Python script designed to be run in Pythonista for iOS. This script will take a URL from the clipboard or via a bookmarklet and convert the referenced web page in to Markdown using Bret Terpstra's site http://heckyesmarkdown.com

Bookmarklet to run script using current page's URL:
javascript:(function()%7Bif(document.location.href.indexOf('http')===0)document.location.href='pythonista://marky?action=run&argv='+document.location.href;%7D)();

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