2011-09-08 00:31:08 -04:00
|
|
|
---
|
|
|
|
layout: page
|
|
|
|
title: "Backtick Code Blocks"
|
|
|
|
date: 2011-07-26 23:42
|
|
|
|
sidebar: false
|
|
|
|
footer: 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.
|
|
|
|
|
|
|
|
#### Syntax
|
|
|
|
|
|
|
|
|
2012-05-27 03:04:45 -04:00
|
|
|
``` [language] [title] [url] [link text] [start:#]
|
2011-09-08 00:31:08 -04:00
|
|
|
code snippet
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
#### Example (plain)
|
|
|
|
|
|
|
|
```
|
|
|
|
$ sudo make me a sandwich
|
|
|
|
```
|
|
|
|
|
2012-05-28 05:22:41 -04:00
|
|
|
``` linenos:false
|
2011-09-08 00:31:08 -04:00
|
|
|
$ sudo make me a sandwich
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Example With Syntax Highlighting a Caption and Link
|
|
|
|
|
|
|
|
``` ruby Discover if a number is prime http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ Source Article
|
|
|
|
class Fixnum
|
|
|
|
def prime?
|
|
|
|
('1' * self) !~ /^1?$|^(11+?)\1+$/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
``` ruby Discover if a number is prime http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ Source Article
|
|
|
|
class Fixnum
|
|
|
|
def prime?
|
|
|
|
('1' * self) !~ /^1?$|^(11+?)\1+$/
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
2012-05-27 03:04:45 -04:00
|
|
|
|
|
|
|
#### Example with a custom starting line number
|
|
|
|
|
2012-05-28 05:22:41 -04:00
|
|
|
``` coffeescript Coffeescript Tricks start:51 mark:52,54-55
|
2012-05-27 03:04:45 -04:00
|
|
|
# Given an alphabet:
|
|
|
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
|
|
|
|
|
|
|
# Iterate over part of the alphabet:
|
|
|
|
console.log letter for letter in alphabet[4..8]
|
|
|
|
```
|
|
|
|
|
2012-05-28 05:22:41 -04:00
|
|
|
``` coffeescript Coffeescript Tricks start:51 mark:52,54-55
|
2012-05-27 03:04:45 -04:00
|
|
|
# Given an alphabet:
|
|
|
|
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
|
|
|
|
|
|
|
# Iterate over part of the alphabet:
|
|
|
|
console.log letter for letter in alphabet[4..8]
|
|
|
|
```
|