2023-10-10 00:06:31 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
from pygments import highlight
|
|
|
|
from pygments.lexers import get_lexer_by_name
|
|
|
|
from pygments.formatters import ImageFormatter
|
|
|
|
from pygments.formatters.img import PilNotAvailable
|
|
|
|
|
|
|
|
lenguaje = get_lexer_by_name("python", stripall=True)
|
|
|
|
|
|
|
|
trozo_codigo = """
|
|
|
|
|
|
|
|
...
|
2023-10-10 00:28:23 +02:00
|
|
|
escribir aqui
|
|
|
|
el código
|
|
|
|
que se quiera
|
|
|
|
generar como imagen
|
2023-10-10 00:06:31 +02:00
|
|
|
...
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
img = highlight(trozo_codigo, lenguaje, ImageFormatter(style='material'), outfile="codigo.png")
|