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