If pygments_lexer is not there, it falls back to name of "R" which is exactly what we wanted all along.
Now for the cool part. In jupyter console, pygments_lexer is used to look up syntax highlighting using the pygments library. So fixing this actually enables R syntax highlighting in jupyter console for ark!
I noticed in https://github.com/posit-dev/positron/issues/2098#issuecomment-2384064069 that in a jupyter console we get this pygment error:
See that
for language ''
? That implies we are actually sending the empty string over for thepygments_lexer
part of thelanguage_info
part of akernel_info_reply
! https://jupyter-client.readthedocs.io/en/stable/messaging.html#kernel-infoNotice that it says
I'm interpreting this as meaning that its actually an optional field. We were treating it as a required
String
, but we sent overString::new()
.And indeed jupyter_console treats it as an optional field! https://github.com/jupyter/jupyter_console/blob/fddbc42d2e0be85feace1fe783a05e2b569fceae/jupyter_console/ptshell.py#L541-L542
If
pygments_lexer
is not there, it falls back toname
of"R"
which is exactly what we wanted all along.Now for the cool part. In jupyter console,
pygments_lexer
is used to look up syntax highlighting using the pygments library. So fixing this actually enables R syntax highlighting in jupyter console for ark!It uses this, with the key being
short name: r
https://pygments.org/docs/lexers/#pygments.lexers.r.SLexer