Back to Genai Toolbox

Ipynb

.hugo/layouts/shortcodes/ipynb.html

1.1.0915 B
Original Source

{{ $notebookFile := .Get 0 }} {{ with .Page.Resources.Get $notebookFile }} {{ $content := .Content | transform.Unmarshal }} {{ range $content.cells }} {{ if eq .cell_type "markdown" }}

{{ $markdown := "" }} {{ range .source }}{{ $markdown = print $markdown . }}{{ end }} {{ $markdown | markdownify }} {{ end }} {{ if eq .cell_type "code" }} {{ $code := "" }} {{ range .source }}{{ $code = print $code . }}{{ end }} {{ highlight $code "python" "" }} {{ range .outputs }} {{ with .text }}

{{- range . }}{{ . }}{{ end -}}

{{ end }} {{ with .data }} {{ with index . "image/png" }} {{ end }} {{ with index . "image/jpeg" }} {{ end }} {{ with index . "text/html" }} {{ $html := "" }} {{ range . }}{{ $html = print $html . }}{{ end }} {{ $html | safeHTML }} {{ end }} {{ end }} {{ end }} {{ end }} {{ end }} {{ else }}

Error: Notebook '{{ $notebookFile }}' not found in page resources.

{{ end }}