From 65a840f62c55e490969750dc808b18ffa19f4522 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bitard=20Micha=C3=ABl?= Date: Sun, 30 Mar 2025 12:17:53 +0200 Subject: [PATCH 1/6] savepoint almost working gemini missing image --- hugo.toml | 22 ++++++++++--- layouts/_default/single.gmi | 64 +++++++++++++++++++++++++++++++++++++ layouts/index.gmi | 18 +++++++++++ layouts/partials/links.gmi | 10 ++++++ 4 files changed, 110 insertions(+), 4 deletions(-) create mode 100644 layouts/_default/single.gmi create mode 100644 layouts/index.gmi create mode 100644 layouts/partials/links.gmi diff --git a/hugo.toml b/hugo.toml index afef130..255671d 100644 --- a/hugo.toml +++ b/hugo.toml @@ -10,10 +10,11 @@ sectionPagesMenu = 'main' pagerSize = 200 [outputs] -home = ["HTML", "RSS", "JSON"] +home = ["HTML", "RSS", "JSON", "GEMINI"] +page = ["HTML", "GEMINI"] [params] -env = "production" # to enable google analytics, opengraph, twitter-cards and schema. +env = "production" description = "Yet another blog on software stuff" author = "Michaël Bitard" @@ -32,7 +33,7 @@ ShowPageNums = true ShowToc = true comments = false images = ["images/home.png"] -hideAuthor=true +hideAuthor = true # homeInfoParams.Title="PaperMod's Demo" # homeInfoParams.Content="👋 Welcome to demo page of Hugo's theme PaperMod!" [params.editPost] @@ -43,9 +44,22 @@ appendFilePath = true # to append fi text = "Yet another blog on software stuff" [markup.goldmark.renderer] - unsafe = true +unsafe = true # FIXME add asciinema # FIXME Languages # [[module.imports]] # path= "https://github.com/hybras/hugo-asciinema" +[mediaTypes] +[mediaTypes.'text/gemini'] +delimiter = '.' +suffixes = ['gmi'] + +[outputFormats] +[outputFormats.GEMINI] +baseName = 'index' +isHTML = false +isPlainText = false +mediaType = 'text/gemini' +protocol = "gemini://" +permalinkable = true diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi new file mode 100644 index 0000000..80f15bc --- /dev/null +++ b/layouts/_default/single.gmi @@ -0,0 +1,64 @@ +# {{ .Title }}{{ $scratch := newScratch }} +{{- $content := .RawContent -}} +{{- $content := $content | replaceRE `#### ` "### " -}} +{{- $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}} +{{- $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}} +{{- $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}} +{{- $content := $content | replaceRE `
` "\n" -}} +{{- $content := $content | replaceRE `\$` "$" -}} +{{- $content := $content | replaceRE `(.+?)` "[$2]($1)" -}} +{{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}} +{{- $content := $content | replaceRE `{{ youtube (.+?) >}}` "=> https://www.youtube.com/watch?v=$1 YouTube Video link to $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 }} +{{- /* Get 'simple links' */}} +{{- 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]" -}} +{{- $linksMD := findRESubmatch `\[(.+?)\]\[(.+?)\]` $content }} +{{- $linksValue := findRESubmatch `\[(.+?)\]:[ ]*(.+)` $content }} +{{- range $linksValue }} +{{- $scratch.Set (index . 1) (index . 2) }} +{{- end }} +{{- $scratch.Set "content" $content }} +{{- range $linksMD }} + {{- $ref := $scratch.Get "ref" }} + {{- $contentInLoop := $scratch.Get "content" }} + {{- $url := (printf "%s[%d]" (index . 1) $ref) }} + {{- $contentInLoop := replace $contentInLoop (index . 0) $url -}} + {{- $scratch.Set "content" $contentInLoop }} + {{- $scratch.Set "ref" (add $ref 1) }} +{{ end }} +{{- $content := $scratch.Get "content" -}} + +{{ $content | safeHTML }} + +--- +## References +{{- $scratch.Set "ref" (add (len $links) 1) }} +{{- range $refs }} +{{- $ref := $scratch.Get "ref" }} +{{- $url := (printf "%s #%d" . $ref) }} +=> {{ $url | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$2 [$3] $1 ($2)" -}} +{{- $scratch.Set "ref" (add $ref 1) }} +{{- end}} +{{- range $linksMD }} +{{- $ref := $scratch.Get "ref" }} +{{- $url := (printf "%s #%d" (index . 1) $ref) }} +=> {{ $scratch.Get (index . 2) }} [{{ $ref }}] {{ index . 1}} ({{ $scratch.Get (index . 2) }}) +{{- $scratch.Set "ref" (add $ref 1) }} +{{- end}} +--- + +=> / Back to the Index +=> https://agileek.github.io{{ replace (replace .RelPermalink "/gemini" "" 1) "index.gmi" "" }} View this article on the WWW diff --git a/layouts/index.gmi b/layouts/index.gmi new file mode 100644 index 0000000..86abfd7 --- /dev/null +++ b/layouts/index.gmi @@ -0,0 +1,18 @@ +## Navigation + +{{ range .RegularPages }} +=> {{ .RelPermalink }} {{ .Title }} +{{- end }} + +## List of posts +{{- if .IsHome }} +{{- $pages := union .RegularPages .Sections }} +{{- $pages = where site.RegularPages "Type" "in" site.Params.mainSections }} +{{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }} + +{{- $paginator := .Paginate $pages }} +{{- range $index, $page := $paginator.Pages }} +=> {{ .RelPermalink }} {{ .Title }} +{{- end }} + +{{- end }} diff --git a/layouts/partials/links.gmi b/layouts/partials/links.gmi new file mode 100644 index 0000000..da8960f --- /dev/null +++ b/layouts/partials/links.gmi @@ -0,0 +1,10 @@ +{{ $scratch := newScratch }}{{ $content := .RawContent -}} +{{- $linksMD := findRESubmatch `\[(.+?)\]\[(.+?)\]` $content }} +{{- $linksValue := findRESubmatch `\[(.+?)\]:[ ]*(.+)` $content }} +{{- $scratch.Set "content" $content }} +{{- range $linksValue }} +{{- $scratch.Set (index . 1) (index . 2) }} +{{- end }} +{{- range $linksMD }} +=> {{ $scratch.Get (index . 2) }} {{ index . 1 }} +{{- end }} From fab4cc4aeb907843fd365b59fea9afe058567fea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bitard=20Micha=C3=ABl?= Date: Sun, 30 Mar 2025 12:50:43 +0200 Subject: [PATCH 2/6] gemini ok ? --- layouts/_default/single.gmi | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index 80f15bc..f80986a 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -1,9 +1,10 @@ -# {{ .Title }}{{ $scratch := newScratch }} +# {{ .Title }} + +{{- $scratch := newScratch }} {{- $content := .RawContent -}} {{- $content := $content | replaceRE `#### ` "### " -}} {{- $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}} {{- $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}} -{{- $content := $content | replaceRE `\[\^(.+?)\]:?` "" -}} {{- $content := $content | replaceRE `
` "\n" -}} {{- $content := $content | replaceRE `\$` "$" -}} {{- $content := $content | replaceRE `(.+?)` "[$2]($1)" -}} @@ -25,11 +26,25 @@ {{- $scratch.Set "ref" (add $ref 1) }} {{- end }} {{- $content := $scratch.Get "content" | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$1 [$3]" -}} -{{- $linksMD := findRESubmatch `\[(.+?)\]\[(.+?)\]` $content }} -{{- $linksValue := findRESubmatch `\[(.+?)\]:[ ]*(.+)` $content }} +{{- $linksValue := findRESubmatch `\[([^^:\]]*)\]:[ ]*(.+)` $content }} +{{- $scratch.Set "content" $content }} {{- range $linksValue }} -{{- $scratch.Set (index . 1) (index . 2) }} + {{- $contentInLoop := $scratch.Get "content" }} + {{- $scratch.Set (index . 1) (index . 2) }} + {{- $contentInLoop := replace $contentInLoop (index . 0) "" -}} + {{- $scratch.Set "content" $contentInLoop }} {{- end }} +{{- $imagesMD := findRESubmatch `!\[(.+?)\]\[(.+?)\]` $content }} +{{- range $imagesMD }} + {{- $contentInLoop := $scratch.Get "content" }} + {{- $url := (printf "![%s](%s)" (index . 1) ($scratch.Get (index . 2) )) }} + {{- $contentInLoop := replace $contentInLoop (index . 0) $url -}} + {{- $scratch.Set "content" $contentInLoop }} +{{- end }} +{{- $content := $scratch.Get "content" -}} +{{- $content := $content | replaceRE `\n\n!\[.*\]\((.+?) \"(.+?)\"\)` "\n\n=> $1 Image: $2" -}} +{{- $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 Embedded Image: $1" -}} +{{- $linksMD := findRESubmatch `\[(.+?)\]\[(.+?)\]` $content }} {{- $scratch.Set "content" $content }} {{- range $linksMD }} {{- $ref := $scratch.Get "ref" }} @@ -38,9 +53,8 @@ {{- $contentInLoop := replace $contentInLoop (index . 0) $url -}} {{- $scratch.Set "content" $contentInLoop }} {{- $scratch.Set "ref" (add $ref 1) }} -{{ end }} +{{- end }} {{- $content := $scratch.Get "content" -}} - {{ $content | safeHTML }} --- From 98b1b077895ac6b4b6f5ab1025cbb9b6d0c0c8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bitard=20Micha=C3=ABl?= Date: Sun, 30 Mar 2025 13:37:49 +0200 Subject: [PATCH 3/6] cleanup --- Makefile | 3 +++ hugo.toml | 1 + layouts/_default/single.gmi | 2 +- layouts/index.gmi | 19 +++++++++---------- layouts/partials/links.gmi | 10 ---------- 5 files changed, 14 insertions(+), 21 deletions(-) delete mode 100644 layouts/partials/links.gmi diff --git a/Makefile b/Makefile index a7f7a16..95a71eb 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,6 @@ test: build: @echo "Building site" @hugo build + +deploy: build + @scp -r public/* server.local.bitard.fr:~/blog/ \ No newline at end of file diff --git a/hugo.toml b/hugo.toml index 255671d..8adbf45 100644 --- a/hugo.toml +++ b/hugo.toml @@ -5,6 +5,7 @@ languageCode = "en-us" title = "Software" enableRobotsTXT = true sectionPagesMenu = 'main' +summaryLength = 0 [pagination] pagerSize = 200 diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index f80986a..58edca8 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -1,4 +1,4 @@ -# {{ .Title }} +# {{ .Title | plainify }} {{- $scratch := newScratch }} {{- $content := .RawContent -}} diff --git a/layouts/index.gmi b/layouts/index.gmi index 86abfd7..95942ee 100644 --- a/layouts/index.gmi +++ b/layouts/index.gmi @@ -1,18 +1,17 @@ ## Navigation {{ range .RegularPages }} -=> {{ .RelPermalink }} {{ .Title }} +=> {{ .RelPermalink }} {{ .Title | plainify }} {{- end }} ## List of posts -{{- if .IsHome }} -{{- $pages := union .RegularPages .Sections }} -{{- $pages = where site.RegularPages "Type" "in" site.Params.mainSections }} -{{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }} - -{{- $paginator := .Paginate $pages }} -{{- range $index, $page := $paginator.Pages }} -=> {{ .RelPermalink }} {{ .Title }} -{{- end }} +{{- if .IsHome }} + {{- $pages := union .RegularPages .Sections }} + {{- $pages = where site.RegularPages "Type" "in" site.Params.mainSections }} + {{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }} + {{- $paginator := .Paginate $pages }} + {{- range $index, $page := $paginator.Pages }} +=> {{ .RelPermalink }} {{ .Title | plainify }}{{ if gt (len .Summary) 0 }} - {{ .Summary | plainify | htmlUnescape }} {{ end }} ({{ .Date.Format ((default "2006/01/02" site.Params.DateFormat)) }}) + {{- end }} {{- end }} diff --git a/layouts/partials/links.gmi b/layouts/partials/links.gmi deleted file mode 100644 index da8960f..0000000 --- a/layouts/partials/links.gmi +++ /dev/null @@ -1,10 +0,0 @@ -{{ $scratch := newScratch }}{{ $content := .RawContent -}} -{{- $linksMD := findRESubmatch `\[(.+?)\]\[(.+?)\]` $content }} -{{- $linksValue := findRESubmatch `\[(.+?)\]:[ ]*(.+)` $content }} -{{- $scratch.Set "content" $content }} -{{- range $linksValue }} -{{- $scratch.Set (index . 1) (index . 2) }} -{{- end }} -{{- range $linksMD }} -=> {{ $scratch.Get (index . 2) }} {{ index . 1 }} -{{- end }} From 0e24123c00bdc9ea5d6f3c0c6745c072d73e199a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bitard=20Micha=C3=ABl?= Date: Sun, 30 Mar 2025 14:41:14 +0200 Subject: [PATCH 4/6] better regex --- layouts/_default/single.gmi | 6 +++--- layouts/index.gmi | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index 58edca8..f5bc924 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -3,10 +3,10 @@ {{- $scratch := newScratch }} {{- $content := .RawContent -}} {{- $content := $content | replaceRE `#### ` "### " -}} +{{- $content := $content | replaceRE `\\\n` "\n" -}} {{- $content := $content | replaceRE `\n- (.+?)` "\n* $1" -}} {{- $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}} {{- $content := $content | replaceRE `
` "\n" -}} -{{- $content := $content | replaceRE `\$` "$" -}} {{- $content := $content | replaceRE `(.+?)` "[$2]($1)" -}} {{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}} {{- $content := $content | replaceRE `{{ youtube (.+?) >}}` "=> https://www.youtube.com/watch?v=$1 YouTube Video link to $1" -}} @@ -34,7 +34,7 @@ {{- $contentInLoop := replace $contentInLoop (index . 0) "" -}} {{- $scratch.Set "content" $contentInLoop }} {{- end }} -{{- $imagesMD := findRESubmatch `!\[(.+?)\]\[(.+?)\]` $content }} +{{- $imagesMD := findRESubmatch `!\[([^^]+?)\]\[(.+?)\]` $content }} {{- range $imagesMD }} {{- $contentInLoop := $scratch.Get "content" }} {{- $url := (printf "![%s](%s)" (index . 1) ($scratch.Get (index . 2) )) }} @@ -44,7 +44,7 @@ {{- $content := $scratch.Get "content" -}} {{- $content := $content | replaceRE `\n\n!\[.*\]\((.+?) \"(.+?)\"\)` "\n\n=> $1 Image: $2" -}} {{- $content := $content | replaceRE `\n\n!\[.*]\((.+?)\)` "\n\n=> $1 Embedded Image: $1" -}} -{{- $linksMD := findRESubmatch `\[(.+?)\]\[(.+?)\]` $content }} +{{- $linksMD := findRESubmatch `\[([^^]+?)\]\[(.+?)\]` $content }} {{- $scratch.Set "content" $content }} {{- range $linksMD }} {{- $ref := $scratch.Get "ref" }} diff --git a/layouts/index.gmi b/layouts/index.gmi index 95942ee..a40d4aa 100644 --- a/layouts/index.gmi +++ b/layouts/index.gmi @@ -12,6 +12,6 @@ {{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }} {{- $paginator := .Paginate $pages }} {{- range $index, $page := $paginator.Pages }} -=> {{ .RelPermalink }} {{ .Title | plainify }}{{ if gt (len .Summary) 0 }} - {{ .Summary | plainify | htmlUnescape }} {{ end }} ({{ .Date.Format ((default "2006/01/02" site.Params.DateFormat)) }}) +=> {{ .RelPermalink }} {{ .Title | plainify }}{{ if gt (len .Summary) 0 }} - {{ .Summary | plainify | htmlUnescape }}{{ end }} ({{ .Date.Format ((default "2006/01/02" site.Params.DateFormat)) }}) {{- end }} {{- end }} From 182be22481a9ed5157e114bddc8a3b477d6eeefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bitard=20Micha=C3=ABl?= Date: Sun, 30 Mar 2025 14:54:33 +0200 Subject: [PATCH 5/6] add rss --- hugo.toml | 8 +++++++- layouts/index.gemini_rss.xml | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 layouts/index.gemini_rss.xml diff --git a/hugo.toml b/hugo.toml index 8adbf45..5fe0748 100644 --- a/hugo.toml +++ b/hugo.toml @@ -11,7 +11,7 @@ summaryLength = 0 pagerSize = 200 [outputs] -home = ["HTML", "RSS", "JSON", "GEMINI"] +home = ["HTML", "RSS", "JSON", "GEMINI", "GEMINI_RSS"] page = ["HTML", "GEMINI"] [params] @@ -64,3 +64,9 @@ isPlainText = false mediaType = 'text/gemini' protocol = "gemini://" permalinkable = true + +[outputFormats.GEMINI_RSS] +baseName = 'feed' +isPlainText = false +mediaType = 'application/rss+xml' +protocol = "gemini://" diff --git a/layouts/index.gemini_rss.xml b/layouts/index.gemini_rss.xml new file mode 100644 index 0000000..ae65bba --- /dev/null +++ b/layouts/index.gemini_rss.xml @@ -0,0 +1,22 @@ + + + {{ .Site.Title }} + {{ i18n "description" }} + {{ (replace .Permalink "https://" "gemini://") | safeURL }} + + {{- if .IsHome }} + {{- $pages := union .RegularPages .Sections }} + {{- $pages = where site.RegularPages "Type" "in" site.Params.mainSections }} + {{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }} + {{- $paginator := .Paginate $pages }} + {{- range $paginator.Pages }} + + {{ .Title | plainify }} + {{ (replace .Permalink "https://" "gemini://") | safeURL }} + {{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }} + {{ (replace .Permalink "https://" "gemini://") | safeURL }} + + {{ end }} + {{ end }} + + \ No newline at end of file From d0d2f9dd3624e31e5137eae2ad573ca9bfdfe716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bitard=20Micha=C3=ABl?= Date: Sun, 30 Mar 2025 16:16:58 +0200 Subject: [PATCH 6/6] prepare blog post on gemini --- content/post/2025-03-30-welcome-gemini.md | 49 +++++++++++++++++++++++ layouts/_default/single.gmi | 3 +- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 content/post/2025-03-30-welcome-gemini.md diff --git a/content/post/2025-03-30-welcome-gemini.md b/content/post/2025-03-30-welcome-gemini.md new file mode 100644 index 0000000..e7fc312 --- /dev/null +++ b/content/post/2025-03-30-welcome-gemini.md @@ -0,0 +1,49 @@ +--- +categories: +- software +date: "2025-03-30T00:00:00Z" +tags: ["software"] +title: Publishing this blog on Gemini +summary: Using Hugo +--- + +TLDR: I have [my blog][blog_gemini] published on gemini. +You can look at my [Pull request][pull_request] if you want to copy/paste the code for Hugo. + +I've looked at [Gemini][gemini] for quite a while, and I wanted to use it for this blog. +Some time ago I used Jekyll and could not found any resource on how to create gemini files from jekyll. + +I switched to Hugo some time ago and I tried to output to gemtext, without success. + +This time I really gave it a try and I think I found a nice setup. + +I relied on 2 blog posts I found, the first one by [Sylvain Durand][sylvaindurand] and the second one by [Brain baking][brainbaking] + +These resources were quite outdated, they both gave up on gemini after quite some time, which I can understand but at the same time makes me sad. + +## Main issue + +My biggest problem is the conversion of links into a Gemtext compatible format. +For those who use the inline syntax (brackets+parentheses), that's pretty straightforward, but I use the markdown indirections, where all my links are at the bottom of the document. + + +First I had to create a map containing all the key/url pairs. +Then replace every link in my document with a reference number. +And finally, display all the references at the end of the document. + +## Build and serve + +You can have a look at this [pull request][pull_request] to glue this together, then you can build and deploy. + +Building is as easy as typing `hugo build`. +To deploy, I used [Agate][agate] server, with the docker image it's as easy as `docker run --name gemini -d --restart unless-stopped -p 1965:1965 -v /path_to_public_folder/:/gmi:ro -v /path_to_certs:/certs ghcr.io/mbrubeck/agate:3.3.14 --hostname blog.bitard.fr` + +From now one, I should by able to publish both on the web and on Gemini \o/ + + +[agate]: https://github.com/mbrubeck/agate +[blog_gemini]: gemini://blog.bitard.fr +[pull_request]: https://github.com/agileek/agileek.github.io/pull/3 +[gemini]: https://geminiprotocol.net/ +[sylvaindurand]: https://sylvaindurand.org/gemini-and-hugo/ +[brainbaking]: https://brainbaking.com/post/2021/04/using-hugo-to-launch-a-gemini-capsule/ diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index f5bc924..a9a6042 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -8,7 +8,6 @@ {{- $content := $content | replaceRE `\n(\d+). (.+?)` "\n* $2" -}} {{- $content := $content | replaceRE `
` "\n" -}} {{- $content := $content | replaceRE `(.+?)` "[$2]($1)" -}} -{{- $content := $content | replaceRE `\sgemini://(\S*)` " [gemini://$1](gemini://$1)" -}} {{- $content := $content | replaceRE `{{ youtube (.+?) >}}` "=> https://www.youtube.com/watch?v=$1 YouTube Video link to $1" -}} {{- $content := $content | replaceRE "([^`])<.*?>([^`])" "$1$2" -}} {{- $content := $content | replaceRE `\n\n!\[.*\]\((.+?) \"(.+?)\"\)` "\n\n=> $1 Image: $2" -}} @@ -26,7 +25,7 @@ {{- $scratch.Set "ref" (add $ref 1) }} {{- end }} {{- $content := $scratch.Get "content" | replaceRE `\[(.+?)\]\((.+?)\) #(\d+)` "$1 [$3]" -}} -{{- $linksValue := findRESubmatch `\[([^^:\]]*)\]:[ ]*(.+)` $content }} +{{- $linksValue := findRESubmatch `\[([^^:\]]*)\]:[ ]*(.+)\n` $content }} {{- $scratch.Set "content" $content }} {{- range $linksValue }} {{- $contentInLoop := $scratch.Get "content" }}