Making a SearchLink TextExpander Snippet (and Some Troubleshooting Too)

While I’ve been sitting around the house the past few days on paternity leave, I’ve gotten eager to fiddle with something. I decided it was time to create a TextExpander snippet that I’ve been meaning to make for a long time: turn the different search operators for Brett Terpstra’s SearchLink service into a snippet. Brett has built an amazing set of Mac OS X services for writing in Markdown. He also built SearchLink, which is a way to quickly make markdown links without having to go and navigate to a million different sites. I’ve always loved the service, but have found myself not using it very often because I have trouble remembering the search operators. So today, while my 21 month old daughter was down for a nap, I started my work.

Everything was going great. I entered all the different search operators I thought I’d use. I never plan to use App.net, define, or Last.fm operators so I left those out. After figuring out how to handle the "optional search text", I had my snippet working. It was time for a test run.

I tried to do a simple search:

[great iPad calendar app](!itu “fantastical for iPad”)

hoping to see a markdown link that would look something like this:

[great iPad calendar app](https://itunes.apple.com/us/app/fantastical-2-for-ipad-calendar/id830708155?mt=8&uo=4&at=11l8rP&ct=searchlink)

But, instead I kept getting this:

[great calendar app](http://lifehacker.com/5833969/the-best-calendar-app-for-iphone)

I went back through all of Brett’s instructions. At first I thought that I’d forgotten to install the Xcode Command Line Tools on my new Macbook Pro. So I logged into my developer account and downloaded the Command Line Tools (OS X Mavericks) for Xcode – March 2014 because the xcode-select --install command wasn’t working from the command line.

Next I tried to make sure that I had the JSON gem installed correctly, so I ran the old sudo gem install json. That kept returning errors for me, so I figured that I might be running into an problem with it parsing my search wrong and then doing a fallback to the Google results. I spent about an hour doing various searches through StackExchange trying to figure out how I could fix my Ruby troubles. Finally, I gave up on that.

Then I read that I should install the Command Line Tools (OS X Mavericks) for Xcode – Late October 2013 because of some sort of deprecated functionality in the 2014 tools. I tried that and while that appeared to help some of my Ruby errors (I could now get the JSON gem to install), it was still throwing off errors like:

unable to convert "\xCF" from ASCII-8BIT to UTF-8 for lib/json/ext/generator.bundle, skipping
unable to convert "\xCF" from ASCII-8BIT to UTF-8 for lib/json/ext/parser.bundle, skipping

I figured those errors were what was causing the issue, so after about 2 hours of fiddling (including some permissions repairing, holding a newborn in one arm while trying to update Ruby, and another incident involving a serious poopy diaper from my 21 month old) I decided to just go and ask the developer, Brett, if he had any ideas.

Brett was gracious to do some troubleshooting with me. He told me that I shouldn’t be getting any results if the JSON gem wasn’t installed and that he was running stock Xcode Command Line Tools and the version of Ruby that came with OS X Mavericks. He ran the exact same search on his machine and got the correct results.

That got me thinking that I needed to go back to the basics. I started looking at making sure my search was EXACTLY the same as his. Then, somehow, it hit me: I’m using smart quotes. You know, those beautiful little quotes with the rounded edges.

Yes. Those. I lost almost 3 hours of my life to those dang things. They are gorgeous and they are a killer in Markdown.

Lesson learned: DO NOT USE SMART QUOTES IN MARKDOWN!

So with that figured out I was finally able to test my little TextExpander snippet properly. And it works beautifully. I’ve already used the snippet a fair amount in writing this post. I’m hoping that it will be a crutch until I can simply remember the search operators. Until then, happy expanding!

Download the SearchLink TextExpander Search Operator Snippet here.

A note to those on iOS: this snippet doesn’t work well with apps that sync to TextExpanderTouch on iOS like Drafts, Editorial for iPad[1], or Byword because it uses the pop-up menu. That feature is only available directly in the TEtouch app. Not to mention SearchLink* is a Ruby script and as far as I know, you can only run Python scripts on iOS.*


  1. Although Editorial developer Ole Moritz ported SearchLink to Editorial so as long as you can remember the search operators, you’re golden.  ↩
Advertisements

One thought on “Making a SearchLink TextExpander Snippet (and Some Troubleshooting Too)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s