Jump to content
Hackademic

mac (Archived) Wikify Evernote via Applescript

Recommended Posts

Like many users (I imagine), I initially fell in love with Evernote and its ability truly to be my external brain. I have used it extensively this year (my first year of grad school). However, I began to flirt with alternatives in the wiki-verse because I really love the idea of what I call Organic Horizontal Organization; that is, a form of organization at the base level of notes (or pages, or documents, or what ever you call your base note form) that is interconnected among itself, creating an inter-locking, inter-linking web. This is the true power of wikis. As a Mac user, I worked with Voodoopad for a while. I was excited to text the power of a personal wiki to really utilize both Internal (within the program) and External (to other programs files) Links. 

 

Although I loved to no hassle internally linking to other Voodoopad pages (simply type a WikiWord and a new page is created; if a page exists and you type its title somewhere, it is automatically linked), I did not love the Interface. Specifically, I felt it greatly lacked a means of powerful Vertical Organization; that is, the nested organization with multiple levels seen in Finder, for example. This was always one of my favorite aspects of EN as well, with the Stacks and Notebooks. 

 

I also found it cumbersome for External Linking. While it was almost magical how easily Voodoopad linked to voodoopad pages, it was quite the hassle to link to external files. I was particularly frustrated by this fault because I take advantage of numerous apps now creating their own custom URL schemes to create an inter-linked knowledge base across my various applications. In struggling to automate external link creation in Voodoopad via Applescript, I stumbled across Markdown (I'm late to the game, I know). While I had seen simply Markdown syntax before (# for header, etc), I had not seen the Markdown linking syntax. It is quite simple, and being plain text, easily automated. Unfortunately, while Voodoopad can export its documents from Markdown to HTML, it cannot easily view Markdown as HTML within the program. Thus my cross-app links look quite ugly. Evernote, however, presents HTML notes beautifully.

 

 

So I wrote two Applescripts to create Wiki-like functionality within Evernote. The essential tools Applescript and the Markdown2Evernote command for TextMate (which can also be a Service for any text editor. More information here (http://blog.timlockridge.com/blog/2013/02/03/using-textmate-and-markdown-with-evernote-configuring-a-workflow/) and here (http://nsuserview.kopischke.net/post/6223792409/i-can-has-some-markdown). Other than that, the scripts run text manipulations and Evernote searches to get what I want. My goal is to mimic the key functionality of Internal Linking in personal wiki programs:

[1] to autolink to new notes that are created without having to leave the current note

[2] to autolink to pre-existing notes without having to leave the current note

 

Each script performs one of these functions. In the future, I will try to combine them into one autolinking script.

I have initial versions of both scripts in the Developer's section of the forum (http://discussion.evernote.com/topic/38682-wikify-evernote-via-applescript/). But I wanted to give as many people access as possible. Plus, I updated both scripts. 

 

I have attached both scripts as .txt files below. I would love for people to test them and see how they work. They have detailed preambles that explain what they do and how to get them to work, but I will replicate the essential details here. 

 

[1] To autolink to new notes:

This script take the selected note and makes it an Index Page for Wiki-Style sub-pages created in a seperate Notebook that is entitled the same as your Note. It uses WikiWords and [[bracketed]] words as the base for the newly created notes. To use, you simply type up a note and put in WikiWords or a term in [[double brackets]]. When the note is finished, run the script, and you will now have an Index-like note with in-text links to new notes in a new notebook with your notes title. 
NOTE: You may either type WikiWords or [[bracketed]] words, but multiple words within brackets (i.e. [[multiple words]]) will create 2 notes: "multiple" and "words". 
 
[2] To autolink to pre-existing notes:
This script searches for matches in the current EN note to pre-existing Wiki notes and links to them. This can work because the previous script assigns the tag "Wiki" to every note it creates. Thus, all of you notes that are apart of your Wiki web can be searched specifically. It thus mimics the autolinking functionality of personal wikis, such as Voodoopad. To use, you simply either type up a note or go to an existing note and run the script. 
NOTE: For the script to work best, I would highly recommend that you create Unique Titles for your Wiki notes. Although Evernote allows this, it mucks up the precision of this process if you have two notes (for example) that are both titled "WikiWords" and have the tag "Wiki". This could easily happen if you run the first script on two separate notes, both of which contain the term "WikiWords". You would then have two notes in two notebooks with this title. 
To combat this, in the future, I hope to combine both scripts and run them such that new notes with the same title are not created. 
 
Notes and warnings aside, these two scripts can help you to Wikify your Evernote. 
 

 

Wikify Evernote_autolinking to existing notes v.2.txt

Wikify Evernote_autolinking to new notes v.2.txt

  • Like 1

Share this post


Link to post

UPDATE: 

I have found a way to automate sending the Markdown text to Evernote. While assigning a keyboard shortcut to the command in TextMate wouldn't work. I found an amazing handler for UI interaction via Applescript here (http://hints.macworld.com/article.php?story=20060921045743404). With this I was able to build in automatically sending the text from TextMate back to Evernote. I insert the code right before the section where I have Evernote delete the old note. But here is the handler and the command code:

 

--put this before you tell Evernote to delete old note

tell application "TextMate" to activate

menu_click({"TextMate", "Bundles", "Markdown", "Markdown2Evernote"})

 

 

--put this in your SUBROUTINES section

-- `menu_click`, by Jacob Rus, September 2006

on menu_click(mList)

local appName, topMenu, r

 

-- Validate our input

if mList's length < 3 then error "Menu list is not long enough"

 

-- Set these variables for clarity and brevity later on

set {appName, topMenu} to (items 1 through 2 of mList)

set r to (items 3 through (mList's length) of mList)

 

-- This overly-long line calls the menu_recurse function with

-- two arguments: r, and a reference to the top-level menu

tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬

(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))

end menu_click

 

on menu_click_recurse(mList, parentObject)

local f, r

 

-- `f` = first item, `r` = rest of items

set f to item 1 of mList

if mList's length > 1 then set r to (items 2 through (mList's length) of mList)

 

-- either actually click the menu item, or recurse again

tell application "System Events"

if mList's length is 1 then

click parentObject's menu item f

else

my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))

end if

end tell

end menu_click_recurse

Share this post


Link to post

BIG UPDATE:

 

I've totally retooled these functions to work with the Markdown2Evernote Mac OS X Service. For this workflow, you write in Markdown syntax in an external editor and then send that Markdown text to Evernote as a HTML note. I've bundled the autolinking to pre-existing notes and to new notes functions into this service. It is now application agnostic, much faster, and much easier. For a fuller description and a download of the service, see my blog post here: http://bit.ly/17eSfGg 

Share this post


Link to post
Guest
This topic is now closed to further replies.

×
×
  • Create New...