Module: Pygments

Defined in:
lib/rb-pygments.rb

Overview

A wrapper for the Pygments command-line interface.

Class Method Summary collapse

Class Method Details

.highlight(source, lexer, formatter, options = {}) ⇒ String

Returns the source code, highlighted using the given lexer and formatter. For example, returns HTML markup surrounding the source code for the :html formatter, or LaTeX markup for the :latex formatter.



50
51
52
# File 'lib/rb-pygments.rb', line 50

def highlight(source, lexer, formatter, options = {})
  execute(["-l", lexer, "-f", formatter] + convert_options(options), source)
end

.languagesArray<String>

Returns a list of all langauges supported by Pygments. This list contains the short names of the languages as documented on the Pygments site.



11
12
13
# File 'lib/rb-pygments.rb', line 11

def languages
  @languages ||= languages!
end

.style(style, formatter, options = {}) ⇒ String

Returns the style definitions for a given style and formatter. For example, returns the CSS definitions for the HTML formatter and the LaTeX style definitions for the LaTeX formatter.



30
31
32
# File 'lib/rb-pygments.rb', line 30

def style(style, formatter, options = {})
  execute(["-S", style, "-f", formatter] + convert_options(options))
end