pygments highlight print in jupyter

417 Views Asked by At

I would like to print a string with sql into my jupyter notebook like below enter image description here

This was done manually with pygments, see

Here is what I tried so far

from pygments import highlight
from pygments.lexers import SqlLexer
from pygments.formatters import HtmlFormatter
from IPython.core.display import HTML, display
query = '''
SELECT
   *
FROM
   latest.tmp
'''
display(HTML(highlight(query, SqlLexer(), HtmlFormatter())))

In the output keywords are neither green nor bold. (I am using Jupyterlab.)

enter image description here

1

There are 1 best solutions below

0
PalimPalim On

You need to also set HtmlFormatter(full=True)

enter image description here