Skip to content

Notebooks

Parse and process notebooks

isDirective

typescript
const isDirective = (ln: string) => boolean

Cell

typescript
export type Cell = z.infer<typeof cellSchema>;

RawCell

typescript
export type RawCell = z.infer<typeof rawCellSchema>;

Nb

typescript
export type Nb = z.infer<typeof nbSchema>;

loadNb

typescript
const loadNb = (nbPath: string) => Promise<Nb>

saveNb

typescript
const saveNb = (nb: Nb) => Promise<void>

Get notebook title

Try to get a human readable title for a notebook using the following approach:

  • grab the first md cell in the notebook, and return first h1 inside of
  • if this fails, return notebook filename

getNbTitle

typescript
const getNbTitle = (nb: Nb) => string

Parse cell output

Jurassic needs to be able to convert individual cell output to test that can be displayed inside documentation

getCellOutput

typescript
const getCellOutput = (cell: Cell) => string

Some cells don't contain any output - return empty strings for those

Cells can output text

Cells can output markdown