A syntax filter plugin for Mephisto based on Ultraviolet

Ultraviolet is a syntax highlighting engine based on Textpow. Since it uses Textmate syntax files, it offers out of the box syntax highlighting for more than 50 languages and 20 themes.

Example

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end

  def salute
    puts "Hello #{@name}!"
  end
end

# Create a new object
g = Greeter.new("world")

# Output "Hello World!"
g.salute

Or have a look around my blog (Worst view in IE :p)

Requirements

Installation

  • Oniguruma

    Ubuntu or Debian

    sudo apt-get install libonig-dev

    OS X (MacPorts)

    sudo port install oniguruma5
  • Ultraviolet, Textpow and Oniguruma for Ruby
    sudo gem install -r ultraviolet --include-dependencies
  • Jazzy Filter
    ruby script/plugin install http://svn.punneng.net/projects/mephisto_jazzy_filter

Deploying

  1. Copy $GEM_HOME/ultraviolet-x.x.x/render/xhtml/files/css/your_template_you_like.css to stylesheets folder in your_app/themes/
  2. Copy jazzy.css in mephisto_jazzy_filter/assets to stylesheets folder in your_app/themes/. You can amend it as you want.
  3. Include both of css into your layout.liquid
    {{ 'your_template_you_like.css' | stylesheet }}
    {{ 'jazzy' | stylesheet }}

Usage

Put these codes below into your post.

<filter:jzfilter lang="ruby">puts "I love Mephisto"</filter:jzfilter>

lang can be languages in $GEM_HOME/ultraviolet-x.x.x/syntax/

or

<filter:jzfilter lang="ruby" line_numbers="no">puts "I love Mephisto"</filter:jzfilter>

line_numbers can be 'table'(default), 'inline' or 'no' ('whatever' is 'no' as well)

License

See MIT-LICENSE