Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Rails plugin that provides helpers to highlight code with pretty TextMate-style highlighting.

tree: 4db53461da

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 generators
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
Octocat-spinner-32 install.rb
Octocat-spinner-32 uninstall.rb
README
TmSyntaxHighlighting
====================
** NOTE: You must install ultraviolet *before* installing this plugin. Follow the instructions below.

This plugin allows you to add TextMate themed syntax highlighting to your views.

It requires the Ultraviolet gem, which requires TextPow, which requires oniguruma (both the gem and the system library).

Oniguruma is a regular expression library used by TextPow in order to properly parse TextMate syntax/language files.
It's relatively easy to install, here is the URL for the library:
  http://www.geocities.jp/kosako3/oniguruma/

Then you need to do
  $ gem install ultraviolet  
which should install ultraviolet, textpow, and oniguruma.

Lastly, in order for this plugin to properly copy the syntax CSS files from ultraviolet, ultraviolet must already be installed. In other words, you need to install ultraviolet before installing this plugin.

Example
=======

The plugin adds 2 view helper methods: code and syntax_css

code (helper method) usage
==========================

  code(some_ruby_code, :theme => "twilight", :lang => "ruby", :line_numbers => true)
  
lang and line_numbers are optional. lang will default to plain_text and line_numbers will default to true.

theme can be an array, and one will be chosen at random.

you can set defaults in an initializer:

  # config/initializers/tm_syntax_config.rb
  TmSyntaxHighlighting.defaults = {:theme => "sunburst", :line_numbers => true, :lang => "ruby"}
  
again, theme can be an array and will be chosen at random.


syntax_css (helper_method) usage
================================
lastly, the syntax_css method will include the stylesheet tags for the themes

you can call it with a theme name

  syntax_css("twilight")
  
or if you call it with no options, it will include all the css files for the themes used in this request

  code(some_ruby_code, :theme => "twilight")
  code(some_more_ruby_code, :theme => "sunburst")
  ...
  syntax_css # yields stylesheet tags for both twilight and sunburst
    

Something went wrong with that request. Please try again.