Skip to content

Commit

Permalink
Add lexers.specials.OutputLexer. (#1836)
Browse files Browse the repository at this point in the history
  • Loading branch information
doerwalter committed Jun 7, 2021
1 parent d228fc7 commit faf69c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions pygments/lexers/_mapping.py
Expand Up @@ -334,6 +334,7 @@
'OocLexer': ('pygments.lexers.ooc', 'Ooc', ('ooc',), ('*.ooc',), ('text/x-ooc',)),
'OpaLexer': ('pygments.lexers.ml', 'Opa', ('opa',), ('*.opa',), ('text/x-opa',)),
'OpenEdgeLexer': ('pygments.lexers.business', 'OpenEdge ABL', ('openedge', 'abl', 'progress'), ('*.p', '*.cls'), ('text/x-openedge', 'application/x-openedge')),
'OutputLexer': ('pygments.lexers.special', 'Text output', ('output',), (), ()),
'PacmanConfLexer': ('pygments.lexers.configs', 'PacmanConf', ('pacmanconf',), ('pacman.conf',), ()),
'PanLexer': ('pygments.lexers.dsls', 'Pan', ('pan',), ('*.pan',), ()),
'ParaSailLexer': ('pygments.lexers.parasail', 'ParaSail', ('parasail',), ('*.psi', '*.psl'), ('text/x-parasail',)),
Expand Down
17 changes: 15 additions & 2 deletions pygments/lexers/special.py
Expand Up @@ -12,11 +12,11 @@
import re

from pygments.lexer import Lexer
from pygments.token import Token, Error, Text
from pygments.token import Token, Error, Text, Generic
from pygments.util import get_choice_opt


__all__ = ['TextLexer', 'RawTokenLexer']
__all__ = ['TextLexer', 'OutputLexer', 'RawTokenLexer']


class TextLexer(Lexer):
Expand All @@ -36,6 +36,19 @@ def analyse_text(text):
return TextLexer.priority


class OutputLexer(Lexer):
"""
Simple lexer that highlights everything as ``Token.Generic.Output``.
.. versionadded:: 2.10
"""
name = 'Text output'
aliases = ['output']

def get_tokens_unprocessed(self, text):
yield 0, Generic.Output, text


_ttype_cache = {}

line_re = re.compile('.*?\n')
Expand Down

0 comments on commit faf69c0

Please sign in to comment.