Module: Pygments
- Defined in:
- lib/rb-pygments.rb
Overview
A wrapper for the Pygments command-line interface.
Class Method Summary (collapse)
-
+ (String) highlight(source, lexer, formatter, options = {})
Returns the source code, highlighted using the given lexer and formatter.
-
+ (Array<String>) languages
Returns a list of all langauges supported by Pygments.
-
+ (String) style(style, formatter, options = {})
Returns the style definitions for a given style and formatter.
Class Method Details
+ (String) highlight(source, lexer, formatter, options = {})
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, = {}) execute(["-l", lexer, "-f", formatter] + (), source) end |
+ (Array<String>) languages
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 |
+ (String) style(style, formatter, options = {})
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, = {}) execute(["-S", style, "-f", formatter] + ()) end |