How to start

Make sure you have all the necessary changes to Nestacms for Setting up rack-codehighligher with Nestacms.

Converting a Textmate Syntax bundle

Download the bundle (usually from a github respository) to get ready for conversion. Once you have the Language.tmLanguage convert the language file to a yaml file which should end up with a file name like source.Language.syntax by using this command:

plist2yaml Language.tmLanguage > source.Language.syntax

If you get an error like the following you need to be inside the Language.tmbundle/Syntaxes directory where the .tmLanuage file is located:

/Users/aaron/.rvm/gems/ruby-1.9.2-p320/gems/plist-3.1.0/lib/plist/parser.rb:67:in `read': Is a directory - Varnish.tmbundle (Errno::EISDIR)
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/gems/plist-3.1.0/lib/plist/parser.rb:67:in `initialize'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/gems/plist-3.1.0/lib/plist/parser.rb:28:in `new'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/gems/plist-3.1.0/lib/plist/parser.rb:28:in `parse_xml'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/gems/textpow-1.3.0/bin/plist2yaml:7:in `<top (required)>'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/bin/plist2yaml:19:in `load'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/bin/plist2yaml:19:in `<main>'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval'
  from /Users/aaron/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>'

Load the syntax file into Nestacms

By adding the following code into your app.rb file the syntax will be available:

Textpow::SyntaxNode.load(File.expand_path('public/syntaxes/source.vcl.syntax', Nesta::App.root))

Use the syntax on you files

To apply the syntax I came up with some code for printing code from the app.rb file by making this method:

# load custom syntaxes
Textpow::SyntaxNode.load(File.expand_path('public/syntaxes/source.vcl.syntax', Nesta::App.root))
def print_code(opt={})
  filename = opt[:filename]
  theme = opt[:theme] || "brilliance_black"
  syntax = opt[:syntax]
  show_code = opt[:show_code] || true
  text = + '/public/' + filename)
  processor =
  result = Uv.parse( text, "xhtml", syntax, false, "eiffel")
  haml(:print_code, :layout => false, :locals => { :code => result, :filename => filename })
  case show_code
  when true
    return haml(:print_code, :layout => false, :locals => { :code => result, :filename => filename })
  when false
    return download_link

Now when you want to call some code, make a haml file and include the file with the following:

= print_code("file_with_language.vcl")


To list the availble syntaxes:

uv --list syntaxes
comments powered by Disqus