Houses the core nb2json function and accompanying utils.
Functions exposed from browser and node.
Where processing happens
- -1 - Calling nb2json - yaml filename returned gets formatted
- 0 - nb2json - meta.filename is fixed up right before returning too
- 0 - nb2json - meta.prettify inserts script
- 0 - nb2json - replaceEmojies
- 0 - nb2json - convertNotes
- 1 - get_metadata - yaml is parsed, title, summary, keyValues set
- Source:
Methods
(static) getFlags(source) → {Array.<string>}
Detects special flags in the source code of a notebook cell and handles them accordingly.
Parameters:
Name | Type | Description |
---|---|---|
source |
string | The source code of a notebook cell. |
- Source:
Returns:
An array of detected flags in the cell's source code.
- Type
- Array.<string>
(async, static) nb2json(ipynbPath, verboseopt) → {Object}
Converts a Jupyter Notebook (.ipynb) file to a JSON object containing metadata and content as two distinct entries.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ipynbPath |
string | The path to the Jupyter Notebook file. |
||
verbose |
boolean |
<optional> |
false | If set to true, enables verbose logging for detailed information. |
- Source:
Returns:
An object with metadata and processed content of the notebook.
- Type
- Object
(static) processOutput(source, flags, verboseopt) → {string}
Processes the output of a code cell, applying transformations based on flags and output type.
Strip Flags from output, make details, hide all.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
Object | The output of a code cell. |
||
flags |
Array.<string> | An array of flags affecting the processing. |
||
verbose |
boolean |
<optional> |
false | If set to true, enables verbose logging for detailed information. |
- Source:
Returns:
The processed output content.
- Type
- string
(static) processSource(source, flags, meta, verboseopt) → {string}
Processes the source of a code cell, applying transformations based on flags and metadata.
Strip Flags from text, make details, hide all. Append to pyCode
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string | The source code of a notebook cell. |
||
flags |
Array.<string> | An array of flags affecting the processing. |
||
meta |
Object | Metadata associated with the notebook. |
||
verbose |
boolean |
<optional> |
false | If set to true, enables verbose logging for detailed information. |
- Source:
Returns:
The processed source code.
- Type
- string
(inner) cleanCell(cell, meta, verboseopt) → {string}
Processes an individual cell from a Jupyter Notebook, handling either markdown or code cells.
Returns text or passes cell to 'code cell' processor
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cell |
Object | A cell from a Jupyter Notebook. |
||
meta |
Object | Metadata associated with the notebook. |
||
verbose |
boolean |
<optional> |
false | If set to true, enables verbose logging for detailed information. |
- Source:
Returns:
The processed content of the cell.
- Type
- string
(inner) convertNb(cells, meta, verboseopt) → {Array.<string>}
Processes each cell of a Jupyter Notebook and returns an array of converted content.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cells |
Array.<Object> | An array of cells from a Jupyter Notebook. |
||
meta |
Object | Metadata associated with the notebook. |
||
verbose |
boolean |
<optional> |
false | If set to true, enables verbose logging for detailed information. |
- Source:
Returns:
An array of strings representing the processed content of each cell.
- Type
- Array.<string>
(inner) get_metadata(data) → {Object}
Extracts metadata from the first cell of a Jupyter Notebook, interpreting it as YAML.
Get markdown and check EACH LINE for yaml. Special characters must have a space after them.
The Lines:
# Title
> summary
- key1: value1"
Will return:
{ title: "Title", summary: "summary", key1: "value1" }
Parameters:
Name | Type | Description |
---|---|---|
data |
Array.<Object> | An array of cells from a Jupyter Notebook. |
- Source:
Returns:
An object containing extracted metadata like title, summary, and key-values.
- Type
- Object
(inner) processCode(cell, meta, verboseopt) → {Array.<string>}
Processes a code cell from a Jupyter Notebook, applying various transformations based on flags and output type.
Calls getFlags, processSource, processOutput
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cell |
Object | A code cell from a Jupyter Notebook. |
||
meta |
Object | Metadata associated with the notebook. |
||
verbose |
boolean |
<optional> |
false | If set to true, enables verbose logging for detailed information. |
- Source:
Returns:
An array of strings representing the processed content of the code cell.
- Type
- Array.<string>
(inner) processMarkdown(x) → {string}
Processes markdown content, converting it to HTML, handling special syntax, and applying transformations.
Parameters:
Name | Type | Description |
---|---|---|
x |
string | The markdown content to be processed. |
- Source:
Returns:
The processed HTML content.
- Type
- string