Files
ML-pipeline/helpers.py
T

16 lines
454 B
Python
Raw Normal View History

2025-04-02 21:56:41 -04:00
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:
2025-04-03 17:07:37 -04:00
# debugMod.log("Warning: Language not recognized. Printing without highlighting.")
2025-04-02 21:56:41 -04:00
return code
formatter = TerminalFormatter()
return highlight(code, lexer, formatter)