android.moparisthebest.org/source/docs/plugins/github-style-codeblock/index.markdown
2011-07-27 16:41:45 -04:00

897 B

layout title date sidebar footer
page Github Style Codeblock 2011-07-26 23:42 false false

With the backtick_codeblock filter you can use Github's lovely back tick syntax highlighting blocks. Simply start a line with three back ticks followed by a space and the language you're using. Tab in four spaces for your code snippets, and then finish your code block with three more back ticks.

Syntax

``` language
    code snippet
```

Example

``` ruby
    class Fixnum
      def prime?
        ('1' * self) !~ /^1?$|^(11+?)\1+$/
      end
    end
```
    class Fixnum
      def prime?
        ('1' * self) !~ /^1?$|^(11+?)\1+$/
      end
    end

This is a nice, lightweight way to add a highlighted code snippet. For features like titles and links you'll want to look at the codeblock or include_code liquid tags.