A blogging framework for hackers.

Sharing Code Snippets

Sharing code is important, and blogging about it should be easy and beautiful.
That's why Octopress is packed with features to make blogging your code a breeze.
Though Jekyll comes with support for Pygments syntax highlighting,
Octopress makes it way better. Here's how.

Additional options:

These options don't depend on any previous option and order does not matter.

start:# - Line numbers begin at # (useful for using snippets to reference longer code).

mark:#,#-# - Mark one or more lines of code with the class name "marked". Accepts one number, numbers separated by commas, and number ranges. Example mark:1,5-8 will mark lines 1,5,6,7,8. Note: If you've changed the beginning line number be sure these match rendered line numbers

Other ways to embed code snippets

Gist Embedding

All you need is the gist's id and you can easily embed it in your page. This actually downloads a cache of the gist and embeds it in a <noscript> tag for RSS
readers and search engines, while still using Github's javascript gist embed code for browsers.

If you have a gist with multiple files, you can include files one at a time by adding the name after the gist id.

{% gist 1059334 svg_bullets.rb %}
{% gist 1059334 usage.scss %}

This plugin was initially developed by Brandon Tilly for Jekyll blogs.

Include Code Snippets

Import files on your filesystem into any blog post as embedded code snippets with syntax highlighting and a download link.
In the _config.yml you can set your code_dir but the default is source/downloads/code. Simply put a file anywhere under that directory and
use the following tag to embed it in a post.

Syntax

Basic options

lang:language - Force the syntax highlighter to use this language. By default the file extension is used for highlighing, but not all extensions are known by Pygments.

Additional options:

These options don't depend on any previous option and order does not matter.

start:# - Render a snippet from the file beginning at the specified line.

end:# - Render a snippet from the file ending at the specified line.

range:#-# - Render a specified range of lines from a file (a shortcut for start:# end:#).

mark:#,#-# - Mark one or more lines of code with the class name "marked". Accepts one number, numbers separated by commas, and number ranges. Example mark:1,5-8 will mark lines 1,5,6,7,8. Note: If you've changed the beginning line number be sure these match rendered line numbers

Additional options:

These options don't depend on any previous option and order does not matter.

start:# - Render a snippet from the file beginning at the specified line.

end:# - Render a snippet from the file ending at the specified line.

range:#-# - Render a specified range of lines from a file (a shortcut for start:# end:#).

mark:#,#-# - Mark one or more lines of code with the class name "marked". Accepts one number, numbers separated by commas, and number ranges. Example mark:1,5-8 will mark lines 1,5,6,7,8. Note: If you've changed the beginning line number be sure these match rendered line numbers

Other ways to embed code snippets

Solarized Highlighting

Solarized has a beautiful syntax highlighting color scheme, but reproducing it requires a highly sophisticated highlighting engine.
Pygments (the highlighter Jekyll uses) processes code snippets into styleable HTML, but it isn't nearly as powerful as the highlighting engine in Vim for example.
In order to port Solarized theme to octopress, I processed its test files with Pygments and styled the output with Sass while comparing
them to the Vim rendered versions.

Spaces vs. Tabs

If you use tabs, there is an issue where the first level indentation is shorter than the rest. The cause is currently unknown since lots of text processors are involved. To fix, use spaces. You'll be happier anyway.