mirror of
https://github.com/ION606/ML-pipeline.git
synced 2026-05-14 21:06:54 +00:00
16 lines
454 B
Python
16 lines
454 B
Python
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)
|