def highlight_code(text, lexer_name='<STR_LIT>', **kwargs):
<EOL>lexer_name = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:h>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT:c>': '<STR_LIT>',<EOL>}.get(lexer_name.replace('<STR_LIT:.>', '<STR_LIT>'), lexer_name)<EOL>try:<EOL><INDENT>import pygments<EOL>import pygments.lexers<EOL>import pygments.formatters<EOL>import pygments.formatters.terminal<EOL>formater = pygments.formatters.terminal.TerminalFormatter(bg='<STR_LIT>')<EOL>lexer = pygments.lexers.get_lexer_by_name(lexer_name, ensurenl=False, **kwargs)<EOL>new_text = pygments.highlight(text, lexer, formater)<EOL><DEDENT>except ImportError:  <EOL><INDENT>new_text = text<EOL><DEDENT>return new_text<EOL>
Highlights a block of text using ansi tags based on language syntax.

Args:
    text (str): plain text to highlight
    lexer_name (str): name of language
    **kwargs: passed to pygments.lexers.get_lexer_by_name

Returns:
    str: text : highlighted text
        If pygments is not installed, the plain text is returned.

CommandLine:
    python -c "import pygments.formatters; print(list(pygments.formatters.get_all_formatters()))"

Example:
    >>> text = 'import xdoctest as xdoc; print(xdoc)'
    >>> new_text = highlight_code(text)
    >>> print(new_text)