Displaying Code Snippets

Using liquid curly brackets to generate code blocks:

{% highlight ruby %}
def foo
  puts 'foo'
end
{% endhighlight %}

{% highlight matlab %}
function [output]=multiply(x,y)
  output = x*y;
end
{% endhighlight %}

Renders:

def foo
  puts 'foo'
end
function [output]=multiply(x,y)
  output = x*y;
end

Using Liquid apostrophes to generate code blocks:

  ```ruby
  def foo
    puts 'foo'
  end
  ```
  ```matlab
  function [output]=multiply(x,y)
    output = x*y;
  end
  ```

Renders:

def foo
  puts 'foo'
end
function [output]=multiply(x,y)
  output = x*y;
end

To embed liquid templating into a markdown code block, see Ozzie Liu’s solutions.

If your jekyll engine gives a warning for parsing the liquid syntax, see this bug.