Module Quill.Cell
Notebook cells.
A cell is the atomic unit of a notebook: either a block of text or an executable code block with outputs.
Cell identifiers
val fresh_id : unit -> idfresh_id () is a fresh unique identifier.
Execution outputs
type output = | Stdout of string| Stderr of string| Error of string| Display of {}(*The type for cell execution outputs. A single execution may produce multiple outputs (e.g. stdout text followed by a displayed image).
Stdout sis captured standard output.Stderr sis captured standard error.Error sis an execution error message.Display {mime; data}is rich content identified by MIME type (e.g."text/html","image/png"). Binary data is base64-encoded indata.
type Stdlib.Format.stag += | Display_tag of {}(*Semantic tag for rich display output. When a pretty-printer opens this tag on a formatter configured by the notebook kernel, the payload is emitted as a
*)Displayoutput. On other formatters the tag is silently ignored and only the text content between the open/close tags is printed.
Cell attributes
type attrs = {collapsed : bool;(*When
*)true, the cell renders as a compact one-line bar. Source and outputs are hidden until the user expands the cell. Purely presentational — execution is unaffected.hide_source : bool;(*When
*)true, the code editor is folded away and only outputs are visible. Clicking the placeholder reveals the source. Only meaningful for code cells. Purely presentational — execution is unaffected.
}The type for cell display attributes. All attributes are purely presentational and never affect execution semantics.
val default_attrs : attrsdefault_attrs is {collapsed = false; hide_source = false}.
Cells
type t = private | Code of {id : id;source : string;language : string;outputs : output list;execution_count : int;attrs : attrs;
}| Text of {}(*The type for notebook cells.
Codeis an executable code cell.languageidentifies the kernel (e.g."ocaml").execution_counttracks how many times this cell has been executed (starts at0).Textis a text cell whosesourceis markdown.
The type is private: pattern matching is allowed, but cells must be constructed via
*)codeandtext.
Constructors
code ?id ?language ?attrs source is a code cell with the given source. language defaults to "ocaml". attrs defaults to default_attrs. A fresh identifier is generated when id is not provided.
text ?id ?attrs source is a text cell with the given source. attrs defaults to default_attrs. A fresh identifier is generated when id is not provided.
Accessors
val source : t -> stringsource c is the source text of cell c.
Transformations
set_outputs os c is c with outputs replaced by os. Text cells are returned unchanged.
append_output o c appends o to the outputs of c. Text cells are returned unchanged.
clear_outputs c is c with an empty output list. Text cells are returned unchanged.