Embedded gists

I didn’t know before today that you can easily embed a gist1 in your HTML (or Markdown). Here’s the JavaScript smartquotes function I wrote about a couple of weeks ago.

The embed code, available on the gist page, is just this:

<script src="https://gist.github.com/705071.js?file=smarten.js"></script>

The advantages of embedding a gist are:

To me, the disadvantages of embedding the gist this way are:

Update 12/3/10
Another disadvantage I just learned: the embedded gist doesn’t appear in the RSS feed (not in Google Reader, at least).

As a reminder, this is what source code looks like when I embed it directly in the text of the post:

1:  // Change straight quotes to curly and double hyphens to em-dashes.
2:  function smarten(a) {
3:    a = a.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018");      // opening singles
4:    a = a.replace(/'/g, "\u2019");                             // closing singles & apostrophes
5:    a = a.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c"); // opening doubles
6:    a = a.replace(/"/g, "\u201d");                             // closing doubles
7:    a = a.replace(/--/g, "\u2014");                            // em-dashes
8:    return a
9:  };

The styling and toggling of the line numbers are handled by a homegrown system described here and here.

Overall, I prefer keeping the code in the post, but I’ll keep the embedding option in mind.


  1. Gists are GitHub’s version of Pasties, a text or code excerpt that you’d like to save in the cloud for repeated use and access.