Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/temetra/nbtohtml
A simple external renderer for Jupyter notebook files in Gitea. Considerably faster than running jupyter nbconvert on a Raspberry Pi.
https://github.com/temetra/nbtohtml
Last synced: 11 days ago
JSON representation
A simple external renderer for Jupyter notebook files in Gitea. Considerably faster than running jupyter nbconvert on a Raspberry Pi.
- Host: GitHub
- URL: https://github.com/temetra/nbtohtml
- Owner: Temetra
- License: mit
- Created: 2024-01-30T09:14:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-30T09:29:52.000Z (about 1 year ago)
- Last Synced: 2024-11-28T04:19:16.825Z (2 months ago)
- Language: Go
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nbtohtml - Jupyter notebook HTML converter
## About
A simple external renderer for Jupyter notebook files in Gitea. Considerably faster than running `jupyter nbconvert` on a Raspberry Pi.
## Usage
```powershell
# Powershell example
Get-Content source.ipynb | nbtohtml.exe
```## Gitea installation
The following examples assume you are running Gitea in Docker, with the data volume mapped
```yaml
# Example path
volumes:
- /media/usb0/gitea/data:/data
```Build the binary for `linux/arm64` and copy it to the Gitea data volume (`data/tools/nbtohtml`)
```powershell
# Powershell example
$env:GOOS="linux"; $env:GOARCH="arm64"; go build -o output
```Configure Gitea to render `.ipynb` using the binary (`data/gitea/conf/app.ini`)
```ini
[markup.jupyter]
ENABLED = true
FILE_EXTENSIONS = .ipynb
RENDER_COMMAND = "/data/tools/nbtohtml"
IS_INPUT_FILE = false[markup.sanitizer.jupyter.img]
ALLOW_DATA_URI_IMAGES = true
```In your Jupyter environment, generate CSS files from Pygments and copy to the data volume (`data/gitea/public/assets/css`)
```bash
pygmentize -S staroffice -f html -a ".markup.jupyter pre" > jupyter-light.css
pygmentize -S lightbulb -f html -a ".markup.jupyter pre" > jupyter-dark.css
```Wrap the CSS in each file with the following. Set `prefers-color-scheme` to `light` or `dark` as appropriate
```css
@media (prefers-color-scheme: light) {
.markup.jupyter pre code { white-space: pre; }
.markup.jupyter pre .ln { padding-right:16px; }
/* Contents of CSS here */
}
```Create a custom header template (`data/gitea/templates/custom/header.tmpl`)
```html
```