Created
April 30, 2012 06:00
-
-
Save trey/2555876 to your computer and use it in GitHub Desktop.
TextExpander snippet to create a Markdown link with title from URL's title (from clipboard)
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
#!/usr/bin/env ruby -wKU | |
require 'open-uri' | |
# get the clipboard using pbpaste | |
clip = %x{__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste} | |
URI.parse(clip).open do |f| | |
f.each {|l| | |
if md = (/<title>\s*(.*)\s*<\/title>/iu).match(l) then | |
print '[' + md[1].gsub(/ - Wikipedia, the free encyclopedia/, '') + '](' + clip + ')' | |
end | |
} | |
end |
Finally. Took me 2 hours to find this. Bone Simple, works perfectly. Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[title of page](url)
via http://brettterpstra.com/textexpander-experiments/ and http://snippets.dzone.com/posts/show/3060