Class JupyterCell
java.lang.Object
uk.ac.starlink.ttools.build.JupyterCell
Manages export of a list of lines to the JSON format used for
serialization of Jupyter notebooks (.ipynb files).
Currently only source code cells containing python are supported. The format was reverse-engineered by looking at an ipynb file saved by the Jupyter installation I happen to have on my machine.
- Since:
- 5 Mar 2020
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionJupyterCell(String[] lines) Convenience constructor for an array of lines.JupyterCell(List<String> lines) Constructs a Jupyter code cell based on a given list of source code lines. -
Method Summary
Modifier and TypeMethodDescriptionorg.json.JSONObjecttoJson()Turns this cell into a JSON object, suitable for export.static org.json.JSONObjecttoNotebook(List<JupyterCell> cells) Turns a list of cells into a JSON representation of a notebook, suitable for export to an ipynb file.
-
Constructor Details
-
JupyterCell
-
JupyterCell
Convenience constructor for an array of lines.- Parameters:
lines- lines of code, no trailing newlines required
-
-
Method Details
-
toJson
public org.json.JSONObject toJson() throws org.json.JSONExceptionTurns this cell into a JSON object, suitable for export.- Returns:
- JSON representation of this cell
- Throws:
org.json.JSONException
-
toNotebook
Turns a list of cells into a JSON representation of a notebook, suitable for export to an ipynb file.- Parameters:
cells- list of cells- Returns:
- JSON representation of notebook
- Throws:
org.json.JSONException
-