Python API

Miscellaneous

class myst_nb.ansi_lexer.AnsiColorLexer(*args, **kwds)[source]

Bases: pygments.lexer.RegexLexer

aliases = ('myst-ansi',)
property current_token
flags = 24
name = 'ANSI Color'
process(match)[source]

Produce the next token and bit of text.

Interprets the ANSI code (which may be a color code or some other code), changing the lexer state and producing a new token. If it’s not a color code, we just strip it out and move on.

Some useful reference for ANSI codes:
reset_state()[source]
tokens = {'root': [('\\x1b\\[([^\\x1b]*)', <function AnsiColorLexer.process>), ('[^\\x1b]+', Token.Text)]}