I often want to embed code snippets into my blog posts. I am testing a method with this post that uses gist.github.com. The idea is that you put your code into some repository and then create a reference to it from wherever you want to use that code. The code in the post will auto-magically have nice syntax highlighting, be easy to copy, and modifications can be made independent of the blog post.
It took me about a minute to create this gist: https://gist.github.com/dhan12/6206272.
The gist page gave me this one liner to add to my blog post:
<script src="https://gist.github.com/dhan12/6206272.js"></script>
The output is shown here:
It worked on the first try. I think this will be the way of the future for me.
No comments:
Post a Comment