Documentation ¶
Index ¶
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 DisplayPNG ¶
func DisplayPNG(png []byte)
DisplayPNG displays the given PNG, given as raw bytes.
func DisplaySVG ¶
func DisplaySVG(svg string)
func EmbedImageAsPNGSrc ¶
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 UniqueID ¶
func UniqueID() string
UniqueID returns a unique id that can be used for UpdateHTML. Should be generated once per display block the program wants to update.
func UpdateHTML ¶
func UpdateHTML(id, html string)
UpdateHTML displays the given HTML in the notebook on an output block with the given `id`: the block is created automatically the first time this function is called, and simply updated thereafter.
The contents of these cells 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.
```
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. |