github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

marcoow / highlight

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 10
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

syntax higlighting plugin for Ruby on Rails — Read more

  cancel

http://simplabs.com/#projects

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

updated copyright notice in license file as well 
marcoow (author)
Sat Jan 23 07:10:50 -0800 2010
commit  7b18ef53a9afa929cf30a7bc676d3e6ec08fa5c0
tree    c7b104c35c588538581498277e6b15c004e08972
parent  99f1e8cecc291f08b2c4a0a7fdc6ba165378ec0c
highlight /
name age
history
message
file .gitignore Wed Dec 03 12:41:59 -0800 2008 ignoring spec log file, creating directory for ... [marcoow]
file MIT-LICENSE Sat Jan 23 07:10:50 -0800 2010 updated copyright notice in license file as well [marcoow]
file README.rdoc Sat Jan 23 07:06:12 -0800 2010 updated copyright notice [marcoow]
file Rakefile Fri Sep 18 05:54:39 -0700 2009 added CI rake task; fixed spec task [marcoow]
directory assets/ Thu Nov 06 11:09:10 -0800 2008 added install.rb; updated README [marcoow]
directory doc/ Fri Sep 18 05:54:39 -0700 2009 added CI rake task; fixed spec task [marcoow]
file init.rb Sat Mar 14 10:52:34 -0700 2009 some refactorings, updated README [marcoow]
file install.rb Thu Nov 06 11:19:09 -0800 2008 fixed install.rb [marcoow]
directory lib/ Sun Mar 15 10:10:45 -0700 2009 more tweaks for the highlighting [marcoow]
directory rdoc/ Sat Mar 14 10:52:34 -0700 2009 some refactorings, updated README [marcoow]
directory spec/ Sun Mar 15 10:10:45 -0700 2009 more tweaks for the highlighting [marcoow]
file uninstall.rb Thu Nov 06 09:42:08 -0800 2008 implementation nearly done [marcoow]
README.rdoc

Highlight

Highlight is a simple syntax highlighting plugin for Ruby on Rails. It’s basically a wrapper around the popular pygments.org highlighter that’s written in Python and supports a huge number of languages.

See the API docs at docs.github.com/marcoow/highlight.

The CI server is at ci.simplabs.com/highlight.

Highlight provides a new method that’s available in views:

  highlight(language, code = nil, &block)

language may be either a Symbolor a String (see supported languages below). The code can be passed either as a string or inside a block, e.g.:

  highlight(:ruby, 'class Test; end')

or

  highlight(:ruby) do
    <<-EOF
      class Test
        end
    EOF
  end

To perform the highlighting, the code is first written to a file in /tmp, e.g.:

  /tmp/highlight_1225993290.70882

This file is the passed to pygments that returns the HTML and so on…

Since writing that file, passing its contents on to pygments, retrieve the result etc. takes a while, all highlighted source code should be cached of course, e.g.:

  <% cache do %>
    <%= highlight(:ruby, 'class Test; end') -%>
  <% end %>

Supported Languages

The following languages are supported. All of the paranthesized identifiers may be used as parameters for highlight to denote the language the source code to highlight is written in (use either Symbols or Strings).

  * Actionscript (as, as3, actionscript)
  * Applescript (applescript)
  * bash (bash, sh)
  * C (c, h)
  * Clojure (clojure)
  * C++ (c++, cpp, hpp)
  * C# (c#, csharp, cs)
  * CSS (css)
  * diff (diff)
  * Dylan (dylan)
  * Erlang (erlang, erl, er)
  * HTML (html, htm)
  * Java (java)
  * JavaScript (javascript, js, jscript)
  * JSP (jsp)
  * Make (make, basemake, makefile)
  * Objective-C (objective-c)
  * OCaml (ocaml)
  * Perl (perl, pl)
  * PHP (php)
  * Python (python, (py)
  * RHTML (erb, rhtml)
  * Ruby (ruby, rb)
  * Scala (scala)
  * Scheme (scheme)
  * Smalltalk (smalltalk)
  * Smarty (smarty)
  * SQL (sql)
  * XML (xml, xsd)
  * XSLT (xslt)
  * YAML (yaml, yml)

Installation

Installation is as easy as (for Rails > 2.1):

  ./script/plugin install git@github.com:marcoow/highlight.git

The hightlight.css stylesheet that contains the neccessary style definitions should be copied to your public/stylesheets directory automagically.

If you are on Rails < 2.1, do this from your RAILS_ROOT

  git clone git@github.com:marcoow/highlight.git vendor/plugins/highlight

In this case you would have to copy the hightlight.css stylesheets manually from vendor/plugins/highlight/assets/stylesheets/.

If you don’t have python and pygments installed, you will need that too. For instructions on installing pygments, refer to pygments.org/docs/installation/

TODOs/ future plans

At the moment there are neither TODOs nor future plans. If you want ot suggest any, do so at github.com/marcoow/highlight/issues.

Author

Copyright © 2008-2010 Marco Otte-Witte (simplabs.com), released under the MIT license

Acknowledgements

The actual highlighting is done by Pygments (pygments.org).

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server