class Rouge::Lexers::ConsoleLexer

The {ConsoleLexer} class is intended to lex content that represents the text that would display in a console/terminal. As distinct from the {Shell} lexer, {ConsoleLexer} will try to parse out the prompt from each line before passing the remainder of the line to the language lexer for the shell (by default, the {Shell} lexer).

The {ConsoleLexer} class accepts five options:

  1. lang: the shell language to lex (default: ‘shell`);

  2. output: the output language (default: ‘plaintext?token=Generic.Output`);

  3. prompt: comma-separated list of strings that indicate the end of a prompt (default: ‘$,#,>,;`);

  4. comments: whether to enable comments.

  5. error: comma-separated list of strings that indicate the start of an error message

The comments option, if enabled, will lex lines that begin with a ‘#` as a comment. Please note that this option will only work if the prompt is either not manually specified or, if manually specified, does not include the `#` character.

Most Markdown lexers that recognise GitHub-Flavored Markdown syntax, will pass the language string to Rouge as written in the original document. This allows an end user to pass options to {ConsoleLexer} by passing them as CGI-style parameters as in the example below.

@example <pre>Here’s some regular text.

“‘console?comments=true # This is a comment $ cp foo bar “`

Some more regular text.</pre>