notebook/format
src/notebook/format.tur
defn
node-tag
(node-tag [node : int])
return 0 for prose nodes and 1 for cell nodes.
defn
node-prose
(node-prose [node : int])
extract the md-node handle from a prose node.
defn
node-cell
(node-cell [node : int])
extract the cell handle from a cell node.
defn
nodes-free
(nodes-free [nodes : int])
release a node list and everything it owns.
defn
parse-string
(parse-string [s : cstr])
parse notebook markdown into prose and cell nodes.
defn
parse-file
(parse-file [path : cstr])
read a notebook file from disk and parse it.
defn
nodes->str
(nodes->str [nodes : int])
serialize notebook nodes back to normalized markdown.
defn
nodes-update-cell
(nodes-update-cell [nodes : int cell-id-want : cstr new-source : cstr])
replace the source of a named cell.
Internal definitions
__fmt-nil-value__fmt-list-nil?__fmt-cons__fmt-head__fmt-tail__ok__err__fmt-cstr-eq?__fmt-str-concat__fmt-cstr-as-int__fmt-int-as-cstr__fmt-slurp__fmt-cstr-free__fmt-own-- copy a borrowed string so a concat can consume it. The__fmt-concat-owned-- concatenate two owned strings, releasing both.__fmt-cstr-null?__fmt-node-make__node-prose-make__node-cell-make__lang-from-info__lang-label__span-start__span-end__inject-no-check-attr__block->node-- wrap one markdown block as a prose or cell node.__blocks->nodes__fmt-node-free-- free one NotebookNode struct, not what it points at.__fmt-cons-free-- free one cons cell, leaving its head alone.__fmt-noop-- void no-op, so a cleanup-only `if` has void on both arms.__render-attr-list__render-attrs-- The serialiser hands every caller an owned string. __render-attr-list and__render-node__nodes->str-int__replace-node-if-match-- rewrite the matched cell's source in place.__node-list-has-cell?__replace-node-list