kulriir

Created: 2008-11-05 18:08
Updated: 2016-05-08 16:18
License: mit

README.markdown

kulriir

Syntax highlighting using the kulrii.heroku.com web service.

WHY?

I have historically used ultraviolet for any syntax highlighting. However, in order to use ultraviolet, you need to be able to use the oniguruma library. Unfortunately, some hosting services (like the Media Temple grid service) do not support this library. I needed another solution, and it seemed like something that could be outsourced... the only solution I found seemed to be the pygment.com javascript-based solution. I cobbled together my pygmalion gem, which does the job, but it seemed I could do something myself that didn't rely on an undocumented api.

Installation

Run the following if you haven't already:

$ gem sources -a http://gems.github.com

Install the gem(s):

$ sudo gem install -r sbfaulkner-kulriir

Usage

In ruby...

require 'kulriir'
...
string.highlight
string.highlight(:syntax => 'javascript')
string.highlight(:syntax => 'ruby', :numbers => true)

From the command-line...

Usage: kulriir [options] [file ...]

Options:
    -h, --help              Display this message.
    -n, --numbers           Include line numbers.
    -S, --syntaxes          List all supported syntaxes.
    -s, --syntax=name       The language for the code to be highlighted.
    -T, --themes            List all supported themes.
    -t, --theme=name        The theme to use for code highlighting.

Example

File.read('hello.rb').highlight(:numbers => true)

Results in...

<pre class="mac_classic"><span class="line-numbers">   1 </span> <span class="Keyword">def</span> <span class="FunctionName">hello</span>
<span class="line-numbers">   2 </span>   puts <span class="String"><span class="String">&quot;</span>hello<span class="String">&quot;</span></span>
<span class="line-numbers">   3 </span> <span class="Keyword">end</span>
</pre>

Legal

Author: S. Brent Faulkner brentf@unwwwired.net
License: Copyright © 2008 unwwwired.net, released under the MIT license

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more