ScrollImage
lib/scroll/image.march — Emit image blobs via the __SCROLL_BLOB__ sentinel protocol.
User (or stdlib) code calls these helpers to display images in the notebook:
ScrollImage.png(b64_data) -- display a PNG image
ScrollImage.jpeg(b64_data) -- display a JPEG image
ScrollImage.gif(b64_data) -- display an animated GIF
ScrollImage.webp(b64_data) -- display a WebP image
ScrollImage.svg(b64_data) -- display an SVG image (base64-encoded)
ScrollImage.show(mime, b64) -- display any image MIME typeEach function prints a sentinel block and returns unit: __SCROLL_BLOB__:<mime>:<base64>\n __SCROLL_BLOB_END__\n
The runtime strips these sentinels and passes the (mime, data) pairs to the browser, which renders them with <img src="data:<mime>;base64,<data>">.
Design:
make_sentinel/2is exposed as afnso tests can verify the format.show/2and convenience functions print the sentinel viaprint.- No validation of base64 content — callers are responsible for encoding.
Functions
Display an animated GIF. b64 is the base64-encoded GIF bytes.
Display a JPEG image. b64 is the base64-encoded JPEG bytes.
Build the raw sentinel string for an image blob (for testing / composing).
Display a PNG image. b64 is the base64-encoded PNG bytes.
Display an image with the given MIME type in the notebook output.
b64 must be a valid base64-encoded representation of the image bytes. The browser renders the result as <img src="data:<mime>;base64,<b64>">.
Examples
march> ScrollImage.show("image/png", "aGVsbG8=")
()Display an SVG image. b64 is the base64-encoded SVG+XML bytes.
Display a WebP image. b64 is the base64-encoded WebP bytes.