Code in a blog
06 Aug 2011
My blog posts occasionally have some code, and I've been wondering for a while what the current/best way is to do that.
I was using embedded gists, which look good, have line-numbers, let you select and copy code without including the line numbers, let you later modify the code using git goodness, and have handy view/raw links. But, I ran into a few problems:
- sometimes not all embedded snippets would turn up (I've not tried to debug that)
- I don't really want to depend on inline content hosted by third parties
- I'm not wild about the "This Gist brought to you by GitHub" advertising
- SyntaxHighlighter line-numbers got easily confused by long wrapping lines
- Prettify which wouldn't show up right
- highlight.js which documents custom initialisation that allowed me to integrate it with my jQuery DOM manipulation
and went with a solution that was right under my nose all along:
Jekyll supports Pygments syntax highlighting (see
The easyinstall is trivial, I used the
enabled pygments in
config.yml, and that was that.
It doesn't do non-selecting line-numbers, and there's no raw/view/download etc functionality,
but that's fine; I can always link to a gist.