engfordev Blog

English For Developers

Sharing Code Snippets

« 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.

  • A Sass port of Solarized syntax highlighting created specifically for Octopress.
  • Gist code embedding - by Brandon Tilly.
  • Insert code snippets from your filesystem with a download link.
  • Easy inline code blocks with <figure> and <figcaption> and optional download links.
  • Pygments caching - a Jekyll community plugin.
  • Table based line numbers added with javascript.

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.

Check out the test page to see the results.

Backtick Code Blocks

File /Users/marocchino/Documents/engfordev.github.com/source/docs/plugins/backtick-codeblock/index.markdown could not be found

Gist Embedding

File /Users/marocchino/Documents/engfordev.github.com/source/docs/plugins/gist-tag/index.markdown could not be found

Include Code Snippets

File /Users/marocchino/Documents/engfordev.github.com/source/docs/plugins/include-code/index.markdown could not be found

Inline Code Blocks

File /Users/marocchino/Documents/engfordev.github.com/source/docs/plugins/codeblock/index.markdown could not be found

Also, see Blogging with Plugins and The Octopress plugins page