from pygments import highlight from pygments.lexers import get_lexer_by_name from pygments.formatters import TerminalFormatter import debug as debugMod def highlight_code(code: str, language: str = 'py') -> None: try: lexer = get_lexer_by_name(language) except ValueError: # debugMod.log("Warning: Language not recognized. Printing without highlighting.") return code formatter = TerminalFormatter() return highlight(code, lexer, formatter)