webficient / rack-coderay
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.document | Thu Aug 20 17:54:09 -0700 2009 | |
| |
.gitignore | Thu Aug 20 17:54:09 -0700 2009 | |
| |
MIT-LICENSE | Fri Aug 28 00:55:51 -0700 2009 | |
| |
README.rdoc | Fri Aug 28 00:55:51 -0700 2009 | |
| |
Rakefile | Thu Sep 03 21:25:28 -0700 2009 | |
| |
VERSION | Thu Sep 03 21:26:04 -0700 2009 | |
| |
lib/ | Fri Aug 28 00:55:51 -0700 2009 | |
| |
rack-coderay.gemspec | Thu Sep 03 21:27:20 -0700 2009 | |
| |
resources/ | Fri Aug 28 00:55:10 -0700 2009 | |
| |
test/ | Thu Sep 03 21:25:28 -0700 2009 |
CodeRay Syntax Highlighter for Rack
Rack::Coderay parses text/html markup and replaces code with output from the CodeRay gem (coderay.rubychan.de/), producing syntax highlighting. By default, this component looks for <pre lang="xxxx">…</pre> blocks, where ‘xxxx’ is any of the languages supported by CodeRay (e.g. ‘ruby’). See coderay.rubychan.de/doc/classes/CodeRay/Scanners.html
For more information about the Rack specification, check out rack.rubyforge.org
Installation
Prerequisites:
-Rack gem (sudo gem install rack) -CodeRay gem (sudo gem install coderay)
From Gem:
$ sudo gem install webficient-rack-coderay
With a local working copy:
$ git clone git://github.com/webficient/rack-coderay.git $ rake build && sudo rake install
Usage
Basic Usage
Rack::Coderay is implemented as a piece of Rack middleware and can be used with any Rack-based application. If your application includes a rackup (`.ru`) file or uses Rack::Builder to construct the application pipeline, simply require and use as follows:
require 'rack/coderay' use Rack::Coderay run app
Using with Rails
Add this to your `config/environment.rb`:
# above Rails::Initializer block require 'rack/coderay' # inside Rails::Initializer block config.middleware.use Rack::Coderay
You should now see `Rack::Coderay` listed in the middleware pipeline:
rake middleware
Configuration Options
To override the default markup trigger (<pre lang="xxxx">), you can pass in a css or xpath selector as the second argument:
# Rails example config.middleware.use Rack::Coderay, "//div[@lang]"
To set additional CodeRay gem options, pass a hash as the third argument:
# Rails example
config.middleware.use Rack::Coderay,
"//pre[@lang]",
:line_numbers => :table
Stylesheet
You can grab the latest CSS from the CodeRay site at coderay.rubychan.de/stylesheets/coderay.css.
A copy has been embedded in the Rack::Coderay gem under the /resources directory for your convenience.
Copyright
Copyright © 2009 Phil Misiowiec, Webficient LLC. See MIT-LICENSE for details.
