posted by bmishkin  10/23/2008

Syntax coloring is awesome. How to do it easily in Mephisto? The pieces are all there. CodeRay is a wicked syntax highlighting library written in Ruby, included for free via the filtered_column_code_macro plugin in Mephisto.

Then we get:

1
2
3
4
# I am awesomely colorized and numbered
def mult(a,b)
  @product = a * b
end

instead of

# I am so 1999
def mult(a,b)
  @product = a * b
end


To enable CodeRay, all you need is love css. Just upload your favorite CodeRay css style, either directly into your project, or via ‘Design’ from within Mephisto admin. That’s it – just add and include the right css.

Good CodeRay css styles we found in the ether: one two three four

Once your css is in the project, include it in your default or target liquid layout:


{{'your_coderay_css' | stylesheet}}

and wrap your code in

<macro:code lang="ruby">
YOUR CODE HERE
</macro:code>

That’s it – just add and include the right css.

Next to be done:
  • gracefully disable line numbers
  • work well with other langs (javascript, css)
  • integrate with pre-code tags (like redmine does)
  • docs in mephisto
Thanks to:
  • http://blog.tupleshop.com/2006/7/20/code-syntax-highlighting-in-mephisto-with-coderay
  • http://offtheline.net/2007/1/12/mephisto-stepping-stone-theme
  • technoweenie

Leave a Comment