1
from pygments import highlight
2
from pygments.lexers import guess_lexer
3
from pygments.formatters import HtmlFormatter
4
5
6
def main(code: str = "export function main() { console.log(\"Hello\") }"):
7
lexer = guess_lexer(code)
8
print(f"Detected lang: {lexer.name}")
9
html_gen = highlight(code, lexer, HtmlFormatter())
10
11
return {"html": html_gen}
12