diff options
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/single.gmi | 13 |
1 files changed, 7 insertions, 6 deletions
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 }} |