sawa sawa - 1 year ago 69
Ruby Question

Getting the list of available languages

How can I get the list of available languages (the short symbol to be passed when calling a method that represents the language) for CodeRay syntax highlighter?

I tried

require "coderay"

but that doesn't seem to give the information. (Even if I were able to get the constants that correspond to the languages, I still need another step to get the symbols that correspond to them.)

A related question is, I can do something like:

CodeRay::Scanners::Ruby # => CodeRay::Scanners::Ruby

doesn't include that. Why is that?

Answer Source

Method you are looking for is:

#=> [:c, :clojure, :cpp, :css, :debug, :delphi, :diff, :erb, :go, :groovy,
#    :haml, :html, :java, :java_script, :json, :lua, :php, :python, :raydebug,
#    :ruby, :sass, :scanner, :sql, :taskpaper, :text, :xml, :yaml]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download