render

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package render produces multi-mimetype representations of golars values for Jupyter and other notebook frontends.

HTML mirrors the polars-py table style: a wrapped <table> with a shape caption, dtype subheader, and zebra rows. Markdown is GFM pipe-tables. Plain text reuses dataframe.DataFrame.Format() so it stays bit-identical to the REPL.

Use directly with gonb:

import "github.com/janpfeifer/gonb/gonbui"
import jrender "github.com/Gaurav-Gosain/golars/jupyter/render"

gonbui.DisplayHTML(jrender.HTML(df))

or via the bundled custom kernel (cmd/golars-kernel) which renders every materialised frame as text/plain + text/html automatically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(df *dataframe.DataFrame) string

HTML renders df as a self-contained HTML fragment. No external CSS dependency: all styling is inline so the table renders identically in JupyterLab, classic Notebook, nbviewer, and Quarto exports.

func HTMLWith

func HTMLWith(df *dataframe.DataFrame, lim Limits) string

HTMLWith is HTML with caller-supplied limits.

Styling: borders use currentColor at 25% opacity, headers use currentColor at 100%, dtypes + nulls at 60% / 40%. No filled backgrounds. This way the table inherits the surrounding text colour and reads on light or dark JupyterLab themes without hardcoding either palette.

func Markdown

func Markdown(df *dataframe.DataFrame) string

Markdown renders df as a GFM pipe-table. Useful when the consumer only renders markdown (e.g. some chat UIs) or when copy-pasting into a README.

func MarkdownWith

func MarkdownWith(df *dataframe.DataFrame, lim Limits) string

MarkdownWith is Markdown with caller-supplied limits.

func MimeBundle

func MimeBundle(df *dataframe.DataFrame) map[string]string

MimeBundle returns the multi-mimetype dict Jupyter clients consume. Always includes text/plain; HTML and markdown go alongside so any frontend can pick its richest supported format.

func Text

func Text(df *dataframe.DataFrame) string

Text returns the existing ASCII repr - identical to fmt.Println(df). Lifted into this package so callers reach for one rendering API.

Types

type Limits

type Limits struct {
	MaxRows     int
	MaxCols     int
	MaxCellRune int
}

Limits caps the rendered window so a 10M-row frame doesn't blow up the notebook. Defaults match dataframe.DefaultFormatOptions: head 5 + tail 5, max 8 columns. Set a field to -1 to disable that limit.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits matches polars-py / dataframe.Format defaults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL