From 4fe1d5738fa41e5a8fe0d7270c049690991961cd165e0a4f0fcc3139ebc3d07b Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Fri, 5 May 2023 00:00:00 +0000 Subject: Add link title support to Gemini --- layouts/_default/single.gmi | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'layouts') 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 }} -- cgit v1.2.3