How to get help on a Julia command on a Jupyter notebook?

? parses for me if I choose “Jupyter Kernel” (not “Julia release channel”) as the kernel source:

A separate issue is that the front-end is trying to render the LaTeX version and failing.

The way the Jupyter protocol works is that the backend kernel (here, IJulia.jl) sends output as a dictionary in multiple formats, and the front-end chooses which one it wants to display. Here, IJulia sends text/plain, text/markdown, and text/latex formats for the documentation. The jupyter notebook is rendering the text/markdown format, but apparently VSCode is trying to render the text/latex format and failing. As noted above, you can force VSCode to use text/markdown via

display("text/markdown", Base.Docs.doc("replace"))

but this is a bit awkward. Another workaround is to tell Julia that Markdown.MD should never be displayed as text/latex:

import Markdown
Base.showable(::MIME"text/markdown", ::Markdown.MD) = false

at which point ?replace works:

A longer-term “solution” would to patch IJulia.jl so that it never sends text/latex for Markdown.MD objects, but this is a bit annoying since the front-end is supposed to decide this.

The right thing would be for VSCode to fix this. They shouldn’t display as text/latex if text/markdown is available, since their text/latex display is apparently not fully functional. (However, their markdown rendering does not support LaTeX equations. So they really need to fix both.)

5 Likes