Editorial Workflows

HTML to EN

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Converts markdown to HTML and posts to Evernote default folder. This is an adapted version of a script found online which tries to avoid Unicode errors by per-processing the text in the same way as the email workflow (which seems to be free of those errors).

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
title
Value
File Name
A document must be open... ?
Run the block if
File Name
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
ON
Message
No Document Selected
…End If
Document Text ?
Folded Text
  • Include
  • Replace with:
Set Variable ?
Variable Name
text
Value
Input
Generate Text ?
Text
text
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Set Variable ?
Variable Name
htmltext
Value
Input
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import webbrowser
import console
import keychain
import pickle
import evernote.edam.userstore.constants as UserStoreConstants
import evernote.edam.type.ttypes as Types
from evernote.api.client import EvernoteClient
import markdown2
import editor

#keychain.delete_password('evernote', 'editorial')
login = keychain.get_password('evernote', 'editorial')
if login is not None:
	auth_token = pickle.loads(login)
else:
	token_choice = console.alert('Token Needed', 'A Developer Token is needed. Go get one?', 'Yes', 'I have One', 'Cancel')
	if token_choice == 1:
		webbrowser.open('safari-https://www.evernote.com/Login.action?targetUrl=%2Fapi%2FDeveloperToken.action')
		raise KeyboardInterrupt
	elif token_choice == 2:
		auth_token = console.password_alert('Evernote Developer Token', 'Paste Your Evernote Developer Token')
		pickle_token = pickle.dumps(auth_token)
		keychain.set_password('evernote', 'editorial', pickle_token)
	else:
		raise KeyboardInterrupt



current_text = editor.get_text()
doc_title = workflow.get_variable('title')
html_text = workflow.get_variable('htmltext').encode('utf-8')


client = EvernoteClient(token=auth_token, sandbox=False)
note_store = client.get_note_store()

notebooks = note_store.listNotebooks()


# To create a new note, simply create a new Note object and fill in
# attributes such as the note's title.
note = Types.Note()
note.title = doc_title

note.content = '<?xml version="1.0" encoding="UTF-8"?>'
note.content += '<!DOCTYPE en-note SYSTEM ' \
   '"http://xml.evernote.com/pub/enml2.dtd">'
note.content += '<en-note>' + html_text + '<br/>'
note.content += '</en-note>'

# Finally, send the new note to Evernote using the createNote method
# The new Note object that is returned will contain server-generated
# attributes such as the new note's unique GUID.
created_note = note_store.createNote(note)

#print "Successfully created a new note with GUID: ", created_note.guid

console.hud_alert(doc_title+' saved to the default folder in Evernote','success')