Skip to content

Instantly share code, notes, and snippets.

@artpi
Last active February 10, 2018 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artpi/e7f0806853bedb6b09186c5fde9d9898 to your computer and use it in GitHub Desktop.
Save artpi/e7f0806853bedb6b09186c5fde9d9898 to your computer and use it in GitHub Desktop.
Alfred Evernote Snippets
============================
Script filter:
var q = "{query}";
var values = Application('Evernote').findNotes("notebook:Snippets " + q);
var ret = '<?xml version="1.0"?><items>';
for (var i=0; i<values.length; i++ ) {
var title = values[i].title();
var val = values[i].htmlContent().replace(/<br\/>/g,'{enter}').replace(/<[^>]*?>/g,"");
var sub = values[i].htmlContent().replace(/\n/g,'').replace(/<[^>]*?>/g,"");
ret += '<item arg="'+val+'"><title>' + title + '</title><subtitle>' + sub + '</subtitle></item>';
}
ret += "</items>";
============================
You will need this to properly handle spaces (script filter has trouble with that)
NSAScript (synchronous)
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
on alfred_script(q)
return replace_chars(q, "{enter} ", "\n")
end alfred_script
@lomafor-zz
Copy link

love this! thanks for sharing. 100 times better than Alfred's built in one.

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