android.moparisthebest.org/source/docs/blogging/code/index.markdown

2.3 KiB

layout title date sidebar footer
page Sharing Code Snippets 2011-07-19 18:10 false false

« Previous, Blogging Basics

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.

Check out the test page to see the results.

Backtick Code Blocks

{% render_partial docs/plugins/backtick-codeblock/index.markdown %}

Gist Embedding

{% render_partial docs/plugins/gist-tag/index.markdown %}

Include Code Snippets

{% render_partial docs/plugins/include-code/index.markdown %}

Inline Code Blocks

{% render_partial docs/plugins/codeblock/index.markdown %}

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.

Also, see Blogging with Plugins and The Octopress plugins page