In efforts to post source code to this blog I have found three very quick to implement solutions.  Discussed will be the pros and cons of each and how I have made my decision on which to use.  The three contenders are:

  • PasteBin
  • github:gist
  • SyntaxHighlighter

Pastebin

Visit Pastebin

This is in here just for comparison’s sake. Gist provides all the same features in a much more intuitive and usable manner. However this service is still very straightforward.  This is a free online service which hosts text of any kind and offers a huge variety of languages which are supported.  You also have the ability to save both private and public pastes.  The options for embedding include a Javascript and Iframe solution.  While there appears to be a way to create a new version of a same file I have had problems even trying to view the old versus the new version. github:gist

Example:

github:gist

Visit gist

From the makers of the version control we know and love to be as git gist.  This of course has the same feel as github which is comforting(much less cluttered than Pastebin).  Just like git this service is free to use! Gist has syntax highlighting for all the same languages as github (so any language one will need).  The embedding code is Javascript based.  What really stands out with gist is the ability to add multiple files for a single gist. So for example in my post Easy and Noticeable Mobile Usability I put all three of my separate code snippets in on place on gist which keeps things nice and organized. As one would expect this service also does version control in a easy to follow manner.
Example:

SyntaxHighlighter

Get the Plugin

This last solution is actually a WordPress plugin.  This is by far the quickest and easiest way to just get code into one’s posts.  It is a standard plugin install and once installed one must only wrap the code they want in the post in a source code tag like so: [sourcecode language=”css”] code here [/sourcecode]. (note how the language is defined for the proper highlighting). I have changed the plugin setting to use version 2 this allows source code to wrap preventing a scrollbar from being visible.

Example:

</pre>
<form action="" method="post" name="mobile-usability">Username: <input type="email" name="email" size="20" /></form>
<pre>

Conclusion

I am leaning away from Pastebin and towards gist.  I believe gist has the most intuitive interface of the two and it allows to group multiple files in a single gits. Although I don’t intend to use it much the version control makes sense and is easy to traverse.  I also find it easier to update codes for a post in the gist environment as opposed to working in the HTML editing section of the WordPress editor. So it is all my code in one place, easy to use and easy to drop in to a post.