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