From be81df3de972d42ae20a1905924cfe0c5b7ce4ce Mon Sep 17 00:00:00 2001 From: Jan Pfeifer Date: Sun, 7 Apr 2024 10:17:54 +0200 Subject: [PATCH] Updated info on Javascript support. --- docs/VSCode.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs/VSCode.md b/docs/VSCode.md index 72387a3..91eb7a8 100644 --- a/docs/VSCode.md +++ b/docs/VSCode.md @@ -13,34 +13,32 @@ and hence won't make use of the auto-complete or contextual information that GoN For Python VSCode relies on IntelliSense. -## No Javascript +## Javascript Caveats -VSCode doesn't support notebooks that output javascript by default. So GoNB libraries like -[Plotly](https://pkg.go.dev/github.com/janpfeifer/gonb/gonbui/plotly), or -[widgets](https://pkg.go.dev/github.com/janpfeifer/gonb/gonbui/widgets) won't work. +VSCode does not "render" mimetype `text/javascript` properly, instead it just displays it as text. Hence `gonbui.ScriptJavascript` won't work. -A longer explanation: VSCode has some partial filters to Javascript. For instance, the following doesn't work: +That affects [widgets](https://pkg.go.dev/github.com/janpfeifer/gonb/gonbui/widgets) (it won't work), and +[Plotly](https://pkg.go.dev/github.com/janpfeifer/gonb/gonbui/plotly) (only up to version 0.9.6, after that it +started using `gonbui.DisplayHtml` and should start working). + +Example, the following doesn't work: ```go import "github.com/janpfeifer/gonb/gonbui" %% -gonbui.DisplayHtml(``) +gonbui.ScriptJavascript(``) ``` But the following does: ```go +import "github.com/janpfeifer/gonb/gonbui" + %% -gonbui.DisplayHtml(`
`) +gonbui.DisplayHtml(``) ``` -So there may be a solution to hack around VSCode javascript limitations. But ideally, VSCode would have an official -way to support it. - -**It works**: somehow Javascript started working ... not sure if after I installed [Polyglot](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.dotnet-interactive-vscode) -or something else. Mysteriously, suddenly it works!? If anyone knows what is needed, pls let us know. - ## No WASM It's an experimental feature for GoNB, but in VSCode for various reasons won't work either. @@ -72,4 +70,7 @@ go run . --install --logtostderr --vmodule=goexec=2,specialcmd=2,cellmagic=2,gop * [VSCode Jupyter Notebooks](https://code.visualstudio.com/docs/datascience/jupyter-notebooks) * [Renderers for Jupyter Notebooks in Visual Studio Code](https://github.com/Microsoft/vscode-notebook-renderers): - presumably adds renderes to several specialized mime-types, including a specialized plotly mime type, that one could take advantage of. I haven't tried it. \ No newline at end of file + presumably adds renderes to several specialized mime-types, including a specialized plotly mime type, that one could take advantage of. I haven't tried it. +* [vscode-jupyter wiki: IPyWidgets](https://github.com/microsoft/vscode-jupyter/wiki/Component:-IPyWidgets) (a lot going on!) +* [vscode-jupyter wiki: React WebViews: Variable Viewer, Plot Viewer, and Data Viewer](https://github.com/microsoft/vscode-jupyter/wiki/React-WebViews:-Variable-Viewer,-Plot-Viewer,-and-Data-Viewer) +* [vscode Extension Notebook API Renderer](https://code.visualstudio.com/api/extension-guides/notebook#notebook-renderer) \ No newline at end of file