0.0
No commit activity in last 3 years
No release in over 3 years
rack-pygments - Rack Middleware for Pygments, the syntax highlighter
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0

Runtime

>= 0
 Project Readme
Rack::Pygments
--------------

A rack middleware for Pygments, the syntax highlighter

It will work with any rack based app and Rails app.


Requirements:
-------------

  - Rack (http://rack.rubyforge.org)
  - Pygments (http://pygments.org/)
  - Nokogiri (http://nokogiri.org/)


Install Nokogiri:
-----------------

  sudo gem install nokogiri -s http://gemcutter.org/

Install Pygments:
-----------------

  easy_install pygments


Install Rack::Pygments
----------------------

  sudo gem install rack-pygments -s http://gemcutter.org/


Options (OPTIONAL):
--------

:html_tag   - set html tag (default: highlight)

  Example #1: :html_tag => "hl:code"    #=> <hl:code lang="bash"></hl:code> 
  Example #2: :html_tag => "colorful"   #=> <colorful lang="bash"></colorful>
 
:html_attr  - set html tag's attribute (default: lang)

  Example #1: :html_attr => "style"     #=> <highlight style="bash"></highlight>
  Example #2: :html_attr => "lexer"     #=> <highlight lexer="python"></highlight>


Example:
---------

config.ru:


  require "app"
  require "rack/pygments"

  use Rack::Pygments, :html_tag => "highlight",
                      :html_attr => "lang"

  run Sinatra::Application


app.rb:


require "sinatra"

  get "/" do
    erb :colorme
  end

  __END__

  @@colorme

  <highlight lang="ruby">

    def hello(name)
      puts "Hello #{name.capitalize}!"
    end

  </highlight>

  <highlight lang="python">
    
    def hello(name):
        print "Hello %s!" % name

  </highlight>