from pygments import highlight
from pygments.lexers import guess_lexer
from pygments.formatters import HtmlFormatter
def main(code: str = "export function main() { console.log(\"Hello\") }"):
lexer = guess_lexer(code)
print(f"Detected lang: {lexer.name}")
html_gen = highlight(code, lexer, HtmlFormatter())
return {"html": html_gen}
Submitted by rubenfiszel 669 days ago