Skip to content

Instantly share code, notes, and snippets.

@doitian
Last active August 29, 2015 14:06
Show Gist options
  • Save doitian/1e2c5fdc5ab055c0b518 to your computer and use it in GitHub Desktop.
Save doitian/1e2c5fdc5ab055c0b518 to your computer and use it in GitHub Desktop.
Send OmniFocus 2 Pro tasks to Evernote (create Todos notebook first)
on escapeHtml(theText)
do shell script "ruby -rcgi -e 'ARGV.each {|a| puts CGI.escape_html(%Q<#{a}>)}' -- " & quoted form of theText
end escapeHtml
set theLines to {}
tell application "OmniFocus"
-- If no document is open, open one
tell default document
if number of document window is 0 then
make new document window with properties {bounds:{0, 0, 500, 500}}
end if
end tell
tell front document
tell (first document window whose index is 1)
set theSelectedTasks to value of selected trees of content
repeat with aTask in theSelectedTasks
set end of theLines to "<li><en-todo/> " & "<a href=\"omnifocus:///task/" & (id of aTask) & "\">" & my escapeHtml(name of aTask) & "</a><br/><pre>" & my escapeHtml(note of aTask) & "</pre></li>"
end repeat
end tell
end tell
set the text item delimiters of AppleScript to "\n"
set theLines to theLines as text
end tell
tell application "Evernote"
create note with enml "<ul>" & theLines & "</ul>" notebook "Todos" title ("Todos " & (current date) as text)
set query string of window 1 to "notebook:Todos"
activate
end tell
@doitian
Copy link
Author

doitian commented Sep 24, 2014

Any idea to convert the rich text note to HTML?

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