Create a gist now

Instantly share code, notes, and snippets.

@cs150bf /README.md
Last active Oct 23, 2016

What would you like to do?
Create cross reference links in Evernote [No Ruby] (OSX)

Create cross reference links in Evernote [No Ruby] (OSX)

Create links within a single note. An alternate version for Create cross reference links in Evernote (OSX) that does not require the pasteboard ruby gem.

Requirement

  • OS X (Yosemite and Mavericks)
  • Evernote OSX client (>6.0.0)

Caveat:
This package does not require the pasteboard ruby gem like the original one, but there might be some minor problems. Most evident ones are:

  • after triggering the "Create cross reference" action, please wait 3 seconds without doing anything while the link is being generated. A dialog will pop up to tell you that the link has been generated when the workflow is finished.
  • you won't be able to easily undo the operation (with 'cmd+z', for example).

Installation

Usage

Warning: The generated result (a link + styled anchor) will be written to your clipboard.

See a demo here

  • In Evernote client, select text that you would like to set as "destination", right click and select "Service -> Create Cross Reference". This selected text will be your "anchor".
  • You will be asked to enter a "label" for this destination (default value should be fine most of the time).
  • Next you will be asked to enter the text for the generated link.
  • The selected text will be replaced by a generated link and a styled anchor.
  • Feel free to move the generated link to anywhere you want within the same note. Clicking on this link should take you to your anchor.

Configuration

You can modify create-cross-reference-links-0.applescript to style the generated link/anchor as you like.

Note for developers

Basically, this workflow does the following:

  1. Get selected text, prompt user for label text and link text.
  2. Create two <a> elements of the form: <a href="#label-text">Link text</a> for the link and <a name="label-text">Selected Text</a> for the destination.
  3. Formulate these two elements into the OSX clipboard.
  4. Paste (with cmd + v) and replace the selected text.
  5. Since the Evernote client will automatically add evernote-html-snippet:// to links with href starting with #, use applescript to scan the whole note and get rid of all these redundant strings.

 

As you can see, step 5 is not very elegant as it operates on the html content of the whole note. In the original version, we can use pasteboard to formulate the clipboard/pasteboard data precisely as type com.evernote.ce.raw (a UTI defined by Evernote) so that the Evernote client will not add evernote-html-snippet:// automatically.

gayax commented Oct 23, 2016

Link to Dropbox is down... Any up possible ?

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