Last active
February 10, 2018 17:39
-
-
Save artpi/e7f0806853bedb6b09186c5fde9d9898 to your computer and use it in GitHub Desktop.
Alfred Evernote Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================ | |
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
love this! thanks for sharing. 100 times better than Alfred's built in one.