I actually figured out several different options that we can use to insert code blocks with Octopress
1. Markdown codeblocks:
We have to use 4 spaces or 1 tab to designate that this is a codeblock.
var respond = function(response, data, err) {
var responseObj = {data: data, error: err};
response.writeHead(200, {"Content-Type":"application/json"});
response.write(JSON.stringify(responseObj));
response.end();
};
var arr1 = new Array(arrayLength);
var arr2 = new Array(element0, element1, ..., elementN);
And this is what we get with the 4 spaces, or the tabs removed from the start of the line.
var respond = function(response, data, err) {
var responseObj = {data: data, error: err};
response.writeHead(200, {"Content-Type":"application/json"});
response.write(JSON.stringify(responseObj));
response.end();
};
var arr1 = new Array(arrayLength);
var arr2 = new Array(element0, element1, ..., elementN);
And this is the HTML that is written for you:
1 2 3 4 5 6 7 8 9 |
|
2. Backtick Code Blocks (GitHub Flavored Markdown):
``` [language] [title] [url] [link text]
var respond = function(response, data, err) {
var responseObj = {data: data, error: err};
response.writeHead(200, {"Content-Type":"application/json"});
response.write(JSON.stringify(responseObj));
response.end();
};
var arr1 = new Array(arrayLength);
var arr2 = new Array(element0, element1, ..., elementN);
```
1 2 3 4 5 6 7 8 |
|
3. Codeblocks
{% codeblock [title] [lang:language] [url] [link text] %}
var respond = function(response, data, err) {
var responseObj = {data: data, error: err};
response.writeHead(200, {"Content-Type":"application/json"});
response.write(JSON.stringify(responseObj));
response.end();
};
{% endcodeblock %}
1 2 3 4 5 6 7 8 |
|
Note:
For code-coloring to work, be sure you have Python27 at your Path.