diff options
author | Nicholas Johnson <nick@nicholasjohnson.ch> | 2023-05-05 00:00:00 +0000 |
---|---|---|
committer | Nicholas Johnson <nick@nicholasjohnson.ch> | 2023-05-05 00:00:00 +0000 |
commit | 4fe1d5738fa41e5a8fe0d7270c049690991961cd165e0a4f0fcc3139ebc3d07b (patch) | |
tree | 19d0f02b66a680b93dbb1e61e096f1d1dcf3cee6ecc6bba88f8926e74ea0df2b | |
parent | 46b5a03514b6fdadcedacff68acee1203ae0fdb9bb431be80cc0560fc29ec1d0 (diff) | |
download | hugo-theme-journal-4fe1d5738fa41e5a8fe0d7270c049690991961cd165e0a4f0fcc3139ebc3d07b.tar.gz hugo-theme-journal-4fe1d5738fa41e5a8fe0d7270c049690991961cd165e0a4f0fcc3139ebc3d07b.zip |
Add link title support to Gemini
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | layouts/_default/single.gmi | 13 |
2 files changed, 7 insertions, 7 deletions
@@ -4,4 +4,3 @@ * make non-critical page elements optional * document which Markdown syntax is compatible with Gemini * add color themes -* add link title support to Gemini diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index ee837e3..38a2a8c 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -20,7 +20,7 @@ {{- $rendered_text := print $before_pre $after_pre }} {{- if ($.Page.Params.makerefs | default true) }} - {{- $chunk_refs := findRESubmatch `!?\[(.+?)\]\((.+?)(?:\s+".*?")?\)` $rendered_text }} + {{- $chunk_refs := findRESubmatch `!?\[(.+?)\]\((.+?)(?:\s+"(.+?)")?\)` $rendered_text }} {{- $scratch.Add "refs" $chunk_refs }} {{- range $chunk_refs }} {{- $ref_index = add $ref_index 1 }} @@ -28,7 +28,7 @@ {{- $rendered_text = replace $rendered_text (index . 0) (print $ref_text "[" $ref_index "]") 1 }} {{- end }} {{- else }} - {{- $rendered_text = $rendered_text | replaceRE `(?m)^!?\[(.+?)\]\((.+?)(?:\s+".*?")?\)$` (print "=> $2 " $emoji "$1") }} + {{- $rendered_text = $rendered_text | replaceRE `(?m)^!?\[(.+?)\]\((.+?)(?:\s+"(.+?)")?\)$` (print "=> $2 " $emoji "$1") }} {{- end }} {{- $rendered_text = $rendered_text | replaceRE `(?m)^####{1,3}` "###" }} {{- $rendered_text = $rendered_text | replaceRE `\*{3}(\S|\S.*?\S)\*{3}` "$1" }} @@ -52,10 +52,11 @@ ## Links {{- range $refs }} - {{- $ref_index = add $ref_index 1 }} - {{- $ref_text := index . 1 }} - {{- $ref_link := index . 2 }} -{{ print "=> " $ref_link (emojify " :link: ") $ref_index ": " $ref_text | safeHTML }} + {{- $ref_index = add $ref_index 1 }} + {{- $ref_text := index . 1 }} + {{- $ref_link := index . 2 }} + {{- $ref_title := index . 3 }} +{{ print "=> " $ref_link (emojify " :link: ") $ref_index ": " (cond (ne (len $ref_title) 0) $ref_title $ref_text) | safeHTML }} {{- end }} {{- end }} {{- end }} |