Skip to content

Instantly share code, notes, and snippets.

@trey
Created April 30, 2012 06:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trey/2555876 to your computer and use it in GitHub Desktop.
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)
#!/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
@trey
Copy link
Author

trey commented Apr 30, 2012

@zachharkey
Copy link

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