Editorial Workflows

Evernote Create Note

unlisted 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: This workflow has no description.

Shared by: @hals_pg

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Tags ?
Set Variable ?
Variable Name
tags
Value
Input
Document Text ?
Folded Text
  • Include
  • Replace with:
Convert Multi-Markdown ?
Template
{{CONTENT}}
Smart Quotes
ON
Find / Replace ?
Find
\sid=(.+?)"
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Find / Replace ?
Find
<\/*figure>
  • Case-insensitive (A = a)
  • Case-sensitive (A ≠ a)
  • Regular Expression
Replace with
Set Variable ?
Variable Name
body
Value
Input
Get Current File Name ?
Include Folder
OFF
Include Extension
OFF
Run Python Script ?
Source Code
# -*- coding: utf-8 -*-
import sys
import evernote.edam.type.ttypes as Types
from evernote.api.client import EvernoteClient
import keychain
import workflow
import console


sys.setdefaultencoding('utf-8')

auth_token = keychain.get_password(
	'evernote_utility',
	'dev_token'
)

if auth_token is None:
	auth_token = raw_input('Developer token: ')
	keychain.set_password(
		'evernote_utility',
		'dev_token',
		auth_token
	)

client = EvernoteClient(
	token=auth_token, sandbox=False
)
note_store = client.get_note_store()
note = Types.Note()
note.title = workflow.get_input()
tags_source = workflow.get_variable('tags')

if tags_source != '':
	tags_source = tags_source.split(',')
	tags = []

	for tag in tags_source:
		tags.append(tag.lstrip().rstrip())

	note.tagNames = tags

attr_dict = {
'<h1>': '<h1 style="font-size: 1.8em;">',
'<h2>': '<h2 style="font-size: 1.5em;">',
'<h3>': '<h3 style="font-size: 1.25em;">',
'<h4>': '<h4 style="font-size: 1em;">',
'<h5>': '<h5 style="font-size: .75em;">',
'<h6>': '<h6 style="font-size: .6em;">',
'<hr>': '<hr style="height: 0.2em;border: 0;color: #ccc;background-color: #ccc;">',
'<pre>': '<pre style="border: 1px solid #ccc;border-radius: 3px;padding: .5em;background-color: #f8f8f8;line-height: 1.25em;font-family: monospace;overflow: auto;">',
'<a': '<a style="color: #4183c4;"',
'<table': '<table style="border: 1px solid #ddd;border-collapse: collapse;margin: 1em .5em;"',
'<th style="': '<th style="border: 1px solid #ddd;padding: 6px;background-color: #eee; ',
'<td style="': '<td style="border-width: 1px;padding: 6px;border-style: solid;border-color: #ddd; ',
'<img': '<img style="max-width: 100%;"',
'<ul>': '<ul style="padding-left:1.5em">',
'<ol>': '<ol style="padding-left:1.5em">',
'<dt>': '<dt style="font-weight: bold;">',
'<dd>': '<dd style="margin-left: 1em;">',
'□': '<en-todo/>',
'☑': '<en-todo checked="true"/>'
}

body = workflow.get_variable('body')

for k, v in attr_dict.items():
	body = body.replace(k, v)

note.content = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note>{}</en-note>'''.format(body)

console.show_activity()
created_note = note_store.createNote(note)
console.hide_activity()

console.hud_alert('Saved', 'success', 0.5)