Thursday, November 29, 2012

Everwatch, Evernote, Marked

Updated Instructions

I love Brett Terpstra's Marked, and its integration with Evernote is barebones and cool. Anyway, the instructions are:
  1. Get the everwatch.rb script from here
  2. As written about here change line 8 to say  
    watch_folder = File.expand_path("~/Library/Application Support/Evernote/accounts/Evernote")
  3. Run it in the background by using something
    ~/scripts/everwatch.rb &

I've Been Checking It Out, Now It's Broken!

You'll notice at some point that the script blows up, and if you're observant (or lucky, as I was) you'll note that it's the apostrophes that make it blow up. So replace the line that says:

      # convert the contents to plain text
      txtnote = %x{echo '#{note}'|textutil -stdin -convert txt -stdout}

with this whole shebang

      note = note.gsub("'","APOSTROPHEEE") 
      # convert the contents to plain text
      txtnote = %x{echo '#{note}'|textutil -stdin -convert txt -stdout}
      txtnote = txtnote.gsub("APOSTROPHEEE", "'") 

While I'm here, I'll add my meager attempt to translate the bullets. It actually works (well, so far):

      txtnote = txtnote.gsub("\t•","-")     # 1st indent
      txtnote = txtnote.gsub("\t◦","    -") # 2nd indent becomes 4 spaces
      # evernote numbering, but only one level
      txtnote = txtnote.gsub(/\t\d{1,4}\.\t/, "1. ")  

And then  you'll notice that second level Markdown bullets don't work, so add this:

      txtnote = txtnote.gsub("\302\240", " ") # some bizarre space-looking character textutil or Evernote uses

Then I went crazy and redid the script a bit. Now it opens Marked on it's own (if you have the filetypes associated) and is less brittle to changes. Performance is the same (and Command-S in Evernote does help):

No comments: