Created
November 9, 2012 13:53
-
-
Save Morse-Code/4045748 to your computer and use it in GitHub Desktop.
marky
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)();