hpi-swa / ipolyglot

A polyglot kernel for Jupyter notebooks based on GraalVM.
Other
90 stars 4 forks source link

Add syntax highlighting to notebook cells for different languages. #4

Open niconomaa opened 5 years ago

niconomaa commented 5 years ago

Syntax highlighting is an important aspect of user experience. We want to introduce syntax highlighting in the notebook frontend for supported languages.

jonashering commented 5 years ago

Syntax highlighting w/ the Jupyter project is handled on frontend side and uses the lexers provided w/ the pygment library (http://pygments.org/docs/lexers). Which lexer is used for syntax highlighting is set in the Jupyter Kernel configuration, and consequently must be set at installation time:

'language_info': {
  # Pygments lexer, for highlighting
  # Only needed if it differs from the 'name'
  'pygments_lexer': str,
  ...
}

(see https://jupyter-client.readthedocs.io/en/stable/messaging.html#msging-kernel-info)

Pygments provides a method called guess_lexer(code) which might be useful for our case. However, it might not be compatible with how the API works.