Color syntax for ruby code in Typo


#1

Do you know how get color syntax for Ruby code snippets in Typo? It is
possible, but I do not know how:
http://scottstuff.net/blog/articles/tag/

Is it possible for Typo to get color syntax for other languages,
Python, PHP, etc?


JZ


#2

It’s so easy to do color syntax formatting with the syntax gem. I
recently added this feature to the app on working on so here’s my 4
steps.

  1. install the gem…

gem install syntax

  1. Add the following require statements to the environment.rb file of
    your Rails app:

require ‘syntax’
require ‘syntax/convertors/html’

  1. Write yourself a helper method that does the conversion and
    conveniently wraps the resulting html in a div, for example…

def ruby_to_html(script_str)
convertor = Syntax::Convertors::HTML.for_syntax(‘ruby’)
return %(

#{convertor.convert(script_str)}
)
end
  1. Include a copy of ruby syntax css file in your application, for
    example http://syntax.rubyforge.org/stylesheets/ruby.css

Hope it helps,
Obie


#3

It’s even easier than that in Typo. I’m running 2.5.5, and this is what
I
add:

<typo:code lang=“ruby”>
</typo:code>

If you click on the ‘filters’ tab in the admin pages, you’ll see what
code
filters you’ve got installed. Also, the theme CSS needs to have the
correct
entries for the typocode classes - the built in azure theme does, the
orange
theme does not.