{{- $scratch := newScratch -}}{{- $scratch.Set "ref" 1 -}} => / 💻 [runtimeterror $] {{ if .Params.Date }} {{- $postDate := .Date.Format "2006-01-02" }} {{- $updateDate := .Lastmod.Format "2006-01-02" }} {{- $postDate }}{{ if ne $postDate $updateDate }} ~ {{ $updateDate }}{{ end }} {{- end }} # {{ .Title }} {{/* The bulk of this regex magic was inspired by https://brainbaking.com/post/2021/04/using-hugo-to-launch-a-gemini-capsule/ */}} {{ range $content := split .RawContent "\n\n" }} {{- $blockRef := $scratch.Get "ref" -}} {{- $content := $content | replaceRE `#{4,} ` "### " -}}{{/* reduce headings to a max of 3 levels */}} {{- $content := $content | replaceRE `(?m:^- (.+?)$)` "\n* $1" -}}{{/* convert unordered lists */}} {{- $content := $content | replaceRE `(?m:^(?:\d+). (.+?)$)` "* $1" -}}{{/* convert ordered lists */}} {{- $content := $content | replaceRE `\n?\[\^(.+?)\]:\s*.*` "" -}}{{/* remove footnote definitions */}} {{- $content := $content | replaceRE `\[\^(.+?)\]` "" -}}{{/* remove footnote anchors */}} {{- $content := $content | replaceRE `((?m:^(?:\|.*\|)+\n?)+)` "```\n$1\n```\n" -}}{{/* render markdown tables as plaintext ascii */}} {{- $content := $content | replaceRE "(?m:^`([^`]*)`$)" "```\n$1\n```\n" -}}{{/* convert single-line inline code to blocks */}} {{- $content := $content | replaceRE `\{\{%\snotice.*%\}\}` "<-- note -->" -}}{{/* convert hugo notices */}} {{- $content := $content | replaceRE `\{\{%\s/notice.*%\}\}` "<-- /note -->" -}} {{- $content := $content | replaceRE `(?:(?: