This Week's Sponsor:

Listen Later

Listen to Articles as Podcasts


Create and Share Evernote Notes With Pythonista On iOS

I use Evernote on a daily basis, but there’s no easy and quick way to create new notes and receive their shared URLs on iOS. While I tend to prefer plain text files, Evernote notes are quite useful when I need to share rich text (containing formatting and inline images) with someone else. Sharing via the official Evernote app takes too long[1], and I don’t like the UI of other Evernote clients.

Yesterday, Pythonista developer Ole Zorn posted an installer script for the Python Evernote SDK. By putting together all the necessary dependencies, he created an installer script that will create an “evernote-sdk” sub-folder in Pythonista 1.3; with that, you’ll be able to access the entire Evernote API to create and manage notes – all while taking advantage of the uniqe iOS-related features of Pythonista.

Inspired by Ole’s demoes and the snippets posted by Brett Kelly in the past weeks, I created a script that does exactly what I need: it lets me enter text to save it in an Evernote note that will be shared publicly. If triggered by an app like Drafts or Launch Center Pro, the script will take the text sent by those apps. If formatted in Markdown, the text will be converted to HTML before saving it to Evernote.

Requirements

Install the Evernote SDK inside Pythonista using Ole’s installer.

To use the script, you’ll first need an Evernote account with an assigned developer token. You can generate a new token here; don’t ever share your private token with anyone else, as it’ll grant anyone access to your Evernote account.

To use the token in the script, rather than pasting it as a text string I recommend using the Pythonista keychain.

Obviously, I compiled the script for Pythonista 1.3, which was released last week.

What It Does

The script consider two possible scenarios: text sent from external apps like Drafts or Launch Center Pro, or text entered from Pythonista itself.

If you didn’t invoke the script from an external app, the script will ask you to enter a note title and body. Using your Evernote developer token, it will create a new note in your default notebook, share it, returning the public URL of the note. The script will display the link in the console as a tappable URL, and it’ll also place it in the iOS clipboard.

If the script, however, was triggered by another app, it will count the arguments passed in the URL scheme. If you like to write in Drafts and then launch the script, it’ll treat the first line as the note’s title, and the rest as the body. If you prefer Launch Center Pro, it will use the first keyboard prompt as title, the second as body.

In both cases, Markdown will be converted to HTML using markdown2 with support for footnotes and header IDs. On my iPad mini, a 1000-word, Markdown-formatted note takes around 15 seconds to be processed, saved, and shared in Evernote.

The Script

You can find the full script on GitHub.

This time, I tried to comment the script inline as much as possible. Lines 21–22 construct the first portion of the Evernote public URL using googlechromes:// – the Google Chrome URL scheme for “https://” links. If you want, you can use safari-https:// to open the link in Safari instead.

Lines 29–35 take care of understanding whether the note title and text should be entered in Pythonista or extracted from another app, whereas lines 41–42 convert the body of the note from Markdown to HTML.

The actual note is created and saved in lines 46–72 using Evernote’s own markup language called ENML; lines 73–87 share the note publicly using a note’s unique identifier and generating a “share key”; these two values will complete the final URL, which is printed as a tappable link in the console, and copied to the clipboard.

Below, a video of the script in action. I used Drafts to create a new note and share it through Evernote.

Once the script is done, you’ll be able to view the shared note in the browser or share the links with your friends, who will see the note you just created on evernote.com.

From Other Apps

Thanks to the Pythonista URL scheme, we can launch the script from other apps, passing along text directly in the URL scheme.

As I showed in the video above, you can launch the script from Drafts using this action (it assumes the script is called EvernoteTextShare):

pythonista://EvernoteTextShare?action=run&argv=[[title]]&argv=[[body]]

Or, if you prefer Launch Center Pro, you can create an action like this and use the keyboard prompt to enter title and body:

pythonista://EvernoteTextShare?action=run&argv=[prompt]&argv=[prompt]

Overall, the script is very flexible and requires minimal management after it has been set up for the first time. You can enable x-callback-url to be taken out of Pythonista automatically once the note is uploaded. You can remove the Markdown conversion, or even open another app like, say, a Twitter client to immediately tweet the link to the shared note.

If you have suggestions for improvements (for instance, I didn’t add any code to check for Evernote errors), ping me on Twitter.


  1. I just want to paste/enter some text and immediately receive the public Evernote URL of a shared note. ↩︎

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.