Progress; refactor partial

This commit is contained in:
David Eisinger
2025-02-16 02:04:16 -05:00
parent ea0be970b9
commit 118e61e010
3 changed files with 23 additions and 20 deletions

View File

@@ -1,20 +1,2 @@
# {{ .Title }}
{{ $content := .RawContent -}}
{{ $content = $content | replaceRE `<!--more-->\n+` "" -}}
{{ $content = $content | replaceRE `\[([^\]]+)\]\[(\d+)\]` "$1[$2]" -}}
{{ $content = $content | replaceRE `(?m)^\[(\d+)\]: (.*)$` "=> $2 [$1] $2" -}}
{{ $content = $content | replaceRE `=> (/.+\.pdf)` "=> https://davideisinger.com$1"}}
{{ $content = $content | replaceRE `(?m)\n\n >` "\n\n>" -}}
{{ $content = $content | replaceRE `(?m)\n\n ([A-Z])` " $1" -}}
{{ $audioRE := `<audio controls src="(.*/([^"]+))"></audio>` }}
{{ range findRE $audioRE $content -}}
{{ $url := . | replaceRE $audioRE "$1" | replaceRE ` ` "%20" -}}
{{ $title := . | replaceRE $audioRE "$2" -}}
{{ $content = replace $content . (printf "=> %s %s" $url $title) -}}
{{ end -}}
{{ range findRE `{{<(dither|thumbnail) [^/]+/>}}` $content -}}
{{ $rendered := $.Page.RenderString . -}}
{{ $url := $rendered | replaceRE `(?s).*src="([^"]+)".*` "=> $1" -}}
{{ $content = replace $content . $url -}}
{{ end -}}
{{ $content | safeHTML }}
{{ partial "gemtext.gmi" (dict "content" .RawContent "page" $.Page) }}