Last active
December 18, 2015 07:29
-
-
Save judismith/5746733 to your computer and use it in GitHub Desktop.
Grab the contents of an Evernote note, run it through the shell to clean it up a bit, then send it on to Marky to get markdownified. Finally we write it to the base folder of Google Drive. The idea is to take notes on the go in EN, then upload them to Drive to share with the whole team.
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
tell application "Evernote" | |
if (not (tag named "exported" exists)) then | |
make tag with properties {name:"exported"} | |
end if | |
set matches to find notes "tag:etf" | |
repeat with theNote in matches | |
set myTitle to title of theNote | |
set myTags to tags of theNote | |
set tagList to "" | |
repeat with theTag in myTags | |
if the name of theTag is not "etf" then set tagList to tagList & "#" & name of theTag & ", " | |
end repeat | |
set myBody to HTML content of theNote | |
--set theMsg to do shell script "echo " & quoted form of myBody & space & "| textutil -stdin -stdout -format html -convert html -encoding UTF-8 | tr -s '\\n' ' '" | |
--set theMsg to do shell script "curl -data-urlencode \"html=" & theMsg & "\\&output=markdown\"" & space & "http://heckyesmarkdown.com/go/" | |
set theMsg to do shell script "echo " & quoted form of myBody & space & "| textutil -stdin -stdout -format html -convert html -encoding UTF-8" | |
set theMsg to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theMsg | |
set markedMsg to do shell script "curl http://heckyesmarkdown.com/go/?html=" & theMsg & "\\&output=markdown | sed 's/\\*\\*]/]\\*\\*/g'" | |
set markedMsg to markedMsg & return & return & tagList | |
tell application "Finder" | |
set thePath to (path to home folder as text) & "Google Drive:" & myTitle & ".md" | |
set NewFile to open for access file thePath with write permission | |
--write ((ASCII character 239) & (ASCII character 187) & (ASCII character 191)) to NewFile --> not as «class utf8» | |
write markedMsg to NewFile as «class utf8» | |
close access NewFile | |
end tell | |
unassign tag "etf" from theNote | |
assign tag "exported" to theNote | |
end repeat | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment