Home

Awesome

jekyll-github-sample

Two Jekyll Liquid tags to display a code sample from a file in a public Github repo and provide a reference to it.

Install

  1. Add the gem to your Gemfile.
    gem 'jekyll_github_sample'
    
  2. Install.
    bundle install 
    
  3. Add the gem to your Jekyll _config.yml.
    plugins: 
      - jekyll_github_sample
    
  4. Start Jekyll.

Live Examples

A write up on my Jekyll blog including samples referencing this repo's code, meta.

github_sample Usage

{% github_sample URL_WITH_USERNAME_REPO_AND_FILE <START_LINE_NUMBER> <END_LINE_NUMBER> %}

One can also specify the lines to include based on markings in the file itself. This is done by invoking

{% github_sample URL_WITH_USERNAME_REPO_AND_FILE tag:TAG_NAME %}

And placing the strings [START TAG_NAME] and [END TAG_NAME] anywhere in the lines immediately before and after the content you wish to include.

github_sample_ref Usage

{% github_sample_ref URL_WITH_USERNAME_REPO_AND_FILE %}

Example Usage

This is how you would display, reference and highlight code in your Jekyll post.

{% github_sample_ref /bwillis/versioncake/989237901cb873f96df12be48cbf1239be496bd7/Appraisals %}

{% highlight ruby %}
{% github_sample /bwillis/versioncake/989237901cb873f96df12be48cbf1239be496bd7/Appraisals 0 5 %}
{% endhighlight %}

Thanks!

Thanks to all those who have helped make this really awesome:

License

Jekyll Github Sample is released under the MIT license.