https://github.com/ruivieira/nim-holst
A Nim parser for Jupyter notebooks
https://github.com/ruivieira/nim-holst
jupyter markdown nim parser
Last synced: 3 months ago
JSON representation
A Nim parser for Jupyter notebooks
- Host: GitHub
- URL: https://github.com/ruivieira/nim-holst
- Owner: ruivieira
- License: agpl-3.0
- Created: 2021-04-06T08:14:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-08T21:18:19.000Z (over 4 years ago)
- Last Synced: 2024-12-06T19:38:09.640Z (11 months ago)
- Topics: jupyter, markdown, nim, parser
- Language: Nim
- Homepage: https://ruivieira.github.io/nim-holst/holst.html
- Size: 91.8 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/ruivieira/nim-holst/actions/workflows/test.yml) [](https://builds.sr.ht/~ruivieira/nim-holst/commits/.build.yml?)
# nim-holst

A parser for Jupyter notebooks.
## setup
Add `holst` to your `nimble` project:
```nim
requires "holst"
```
and run `nimble install`
## examples
### reading
Load and parse a Jupyter notebook in `/tmp/foo.ipynb`:
```nim
import holst
let notebook = read("/tmp/foo.ipynb")
```
### metadata
Get the kernel's metadata
```nim
echo notebook.metadata.kernelspec.language # => python
echo notebook.metadata.kernelspec.name # => Python 3
```
### exporting
Export the notebook as markdown
```nim
let md = notebook.markdown()
```
Images are rendered as links in Markdown, you can export the image data to files with
```nim
notebook.image_prefix = "notebook-img"
notebook.image_rel_path = "./my_images"
notebook.image_dest = "/tmp/html/my_images"
notebook.export_images()
```
### iterating
Apply a method to each code cell:
```nim
notebook
.filter(proc(cell: Cell): bool = cell.kind = Cell.Code)
.map (
# do something
)
```
## compatibility
`holst` works with Jupyter notebooks with format 4+.
## mailing lists
- Announcements: [https://lists.sr.ht/~ruivieira/nim-announce](https://lists.sr.ht/~ruivieira/nim-announce)
- Discussion: [https://lists.sr.ht/~ruivieira/nim-discuss](https://lists.sr.ht/~ruivieira/nim-discuss)
- Development: [https://lists.sr.ht/~ruivieira/nim-devel](https://lists.sr.ht/~ruivieira/nim-discuss)
Please prefix the subject with `[nim-holst]`.