Documentation
¶
Index ¶
- Variables
- func DisplayHTML(html string)
- func DisplayImage(image image.Image) error
- func DisplayMarkdown(markdown string)
- func DisplayPNG(png []byte)
- func DisplaySVG(svg string)
- func EmbedImageAsPNGSrc(img image.Image) (string, error)
- func Error() error
- func RequestInput(prompt string, password bool)
- func UniqueID() string
- func UpdateHTML(id, html string)
- func UpdateMarkdown(id, markdown string)
Constants ¶
This section is empty.
Variables ¶
var ( // IsNotebook indicates whether the execution was started by a GoNB kernel. IsNotebook bool )
Functions ¶
func DisplayHTML ¶
func DisplayHTML(html string)
DisplayHTML will display the given HTML in the notebook, as the output of the cell being executed.
func DisplayImage ¶
DisplayImage displays the given image, by converting it to PNG first. It returns an error if it fails to encode to the image to PNG.
func DisplayMarkdown ¶ added in v0.7.7
func DisplayMarkdown(markdown string)
DisplayMarkdown will display the given markdown content in the notebook, as the output of the cell being executed.
func DisplayPNG ¶
func DisplayPNG(png []byte)
DisplayPNG displays the given PNG, given as raw bytes.
func DisplaySVG ¶
func DisplaySVG(svg string)
func EmbedImageAsPNGSrc ¶ added in v0.4.0
EmbedImageAsPNGSrc returns a string that can be used as in an HTML <img> tag, as its source (it's `src` field). This simplifies embedding an image in HTML without requiring separate files. It embeds it as a PNG file base64 encoded.
func Error ¶
func Error() error
Error returns the first error that may have happened in communication to the kernel. Nil if there has been no errors.
func RequestInput ¶ added in v0.7.4
RequestInput from the Jupyter notebook. It triggers the opening of a small text field in the cell output area where the user can type something. Whatever the user writes is written to the stdin of cell program -- and can be read, for instance, with `fmt.Scanf`.
Args:
- prompt: string displayed in front of the field to be entered. Leave empty ("") if not needed.
- password: if whatever the user is typing is not to be displayed.
func UniqueID ¶ added in v0.4.0
func UniqueID() string
UniqueID returns a unique id that can be used for UpdateHTML. It should be generated once per display block the program wants to update.
func UpdateHTML ¶ added in v0.4.0
func UpdateHTML(id, html string)
UpdateHTML displays the given HTML in the notebook on an output block with the given `id`: the block identified by 'id' is created automatically the first time this function is called, and simply updated thereafter.
The contents of these output blocks are considered transient, and intended to live only during a kernel session.
Usage example:
```go
counterDisplayId := gonbui.UniqueID() for ii := 0; ii < 10; ii++ { gonbui.UpdateHTML(counterDisplayId, fmt.Sprintf("Count: <b>%d</b>\n", ii)) } gonbui.UpdateHTML(counterDisplayId, "") // Erase transient block. gonbui.DisplayHTML(fmt.Sprintf("Count: <b>%d</b>\n", ii)) // Show on final block.
```
func UpdateMarkdown ¶ added in v0.7.7
func UpdateMarkdown(id, markdown string)
UpdateMarkdown updates the contents of the output identified by id: the block identified by 'id' is created automatically the first time this function is called, and simply updated thereafter.
The contents of these output blocks are considered transient, and intended to live only during a kernel session.
See example in UpdateHTML, just instead this used Markdown content.
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
Package protocol contains the definition of the objects that are serialized and communicated to the kernel, using the standard Go `encoding/gob` package.
|
Package protocol contains the definition of the objects that are serialized and communicated to the kernel, using the standard Go `encoding/gob` package. |