{{/* Render Jupyter Notebook */}} {{- $path := .Get 0 -}} {{- $data := "" -}} {{- $page := .Page -}} {{/* https://gohugo.io/functions/transform/unmarshal/ */}} {{- with .Page.Resources.Get $path -}} {{- with unmarshal .Content -}} {{- $data = . -}} {{- end -}} {{- else -}} {{- errorf "Resource not found: %s" $path -}} {{- end -}} {{- $language := index $data "metadata" "language_info" "name" | default "python" -}} {{- with index $data "cells" -}} {{- range $cell := . -}} {{- if eq (index $cell "cell_type") "code" -}} {{- $source := index $cell "source" -}} {{- $sourceContent := (cond (reflect.IsSlice $source) (delimit $source "") $source) -}}
{{- else if eq (index $cell "cell_type") "markdown" -}} {{- $source := index $cell "source" -}} {{- $sourceContent := (cond (reflect.IsSlice $source) (delimit $source "") $source) -}} {{- $sourceContent | $page.RenderString -}} {{- end -}} {{- end -}} {{- end -}}