Fix routines for gemini project

This commit is contained in:
HUC Stéphane 2022-05-01 23:29:27 +02:00
parent cddc341b6c
commit 84638c97e1
Signed by: hucste
GPG Key ID: C4ED64222D9B037F
2 changed files with 16 additions and 11 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/public
*.lock

View File

@ -1,15 +1,19 @@
# {{ $.Title | safeHTML }}
# {{ $.Title | safeHTML }}{{ $scratch := newScratch }}
{{ $content := .RawContent -}}
{{ $content := $content | replaceRE "`(.+)`" "$1" -}}
{{ $content := $content | replaceRE "`" "```" -}}
{{ $content := $content | replaceRE "\\*(.+)\\*" "$1" -}}
{{ $content := $content | replaceRE "(?ms)\\*\\*(.+)\\*\\*" "$1" -}}
{{ $content := $content | replaceRE "\\[(.+)\\]: (.+)" "=> $2 $1" -}}
{{ $content := $content | replaceRE " \\[(.+)\\]\\((.+)\\)" "\n\n=> $2 $1\n\n" -}}
{{ $content := $content | replaceRE "\\[(.+)\\]\\((.+)\\)" "=> $2 $1" -}}
{{ $content := $content | replaceRE "<br>" "" -}}
{{ $content }}
{{ $content := $content | replaceRE `#### ` "### " -}}
{{ $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}}
{{ $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}}
{{ $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}}
{{ $content := $content | replaceRE `<br/??>` "\n" -}}
{{ $content := $content | replaceRE `<a .*href="(.+?)".*>(.+?)</a>` "[$2]($1)" -}}
{{ $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}}
{{ $content := $content | replaceRE "([^`])<.*?>([^`])" "$1$2" -}}
{{ $content := $content | replaceRE `\n\n!\[.*\]\((.+?) \"(.+?)\"\)` "\n\n=> $1 Image: $2" -}}
{{ $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 Embedded Image: $1" -}}
{{ $links := findRE `\n=> ` $content }}{{ $scratch.Set "ref" (add (len $links) 1) }}
{{ $refs := findRE `\[.+?\]\(.+?\)` $content }}
{{ $scratch.Set "content" $content }}{{ range $refs }}{{ $ref := $scratch.Get "ref" }}{{ $contentInLoop := $scratch.Get "content" }}{{ $url := (printf "%s #%d" . $ref) }}{{ $contentInLoop := replace $contentInLoop . $url -}}{{ $scratch.Set "content" $contentInLoop }}{{ $scratch.Set "ref" (add $ref 1) }}{{ end }}{{ $content := $scratch.Get "content" | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$1 [$3]" -}}
{{ $content | safeHTML }}
---