Instantly share code, notes, and snippets.

Embed
What would you like to do?
Evernote-Marked integration

Evernote's Mac client + Marked or similar: basically just setting ~/Documents/Evernote Selection.md to the content text of current note converted from HTML to Markdown.

First,

$ [sudo] pip install html2text MacFSEvents

Then launch it and enjoy.

P.S. guess what, ⌘S works in Evernote.

#!/usr/bin/env python
import os
import time
import codecs
from html2text import html2text
from fsevents import Observer, Stream
home = os.environ["HOME"]
now = lambda: time.mktime(time.localtime())
last = now()
def cb(*args):
global last
if now() - last > 1:
codecs.open(os.path.join(home, "Documents/Evernote Selection.md"), "w", "utf-8") \
.write(html2text(os.popen("""osascript -e \
'tell application \"Evernote\"
if selection is not {} then
set the_selection to selection
return HTML content of item 1 of the_selection
else
return \"\"
end if
end tell'""").read().decode("utf-8")))
last = now()
cb()
observer = Observer()
observer.schedule(Stream(cb, os.path.join(home, "Library/Application Support/Evernote/data")))
observer.start()
       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
               Version 2, December 2004

Copyright (C) 2011 Grigory V. floatboth@me.com

Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.

       DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  1. You just DO WHAT THE FUCK YOU WANT TO.
@rezzz-dev

This comment has been minimized.

rezzz-dev commented Jun 20, 2014

I tried to implement this, but for whatever reason it's not working. I did follow the steps within this post and it did not work. I rebooted on top of just login/out.

So I just swapped out the evernote_selection.py he had for yours, and still nada. I've got to be missing something. I didn't notice that I don't have Library/Application Support/Evernote/data directory, should I make that? Is there something else I'm missing?

Any help would be much appreciated, thanks!

@rezzz-dev

This comment has been minimized.

rezzz-dev commented Jun 20, 2014

One step closer -- I ran the script locally by just doing python evernote_selection.py and everything seemed to work as expected. But for whatever reason, the script won't work automatically unless I drop to terminal and run it manually.

I've put the script in /usr/local/bin which is in my $PATH, just not happening automatically for whatever reason. Any thoughts?

@rezzz-dev

This comment has been minimized.

rezzz-dev commented Jun 20, 2014

Nevermind -- I got it -- my plist had the wrong location of the script - 👊

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