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 | d2b1fbae50be9597c17d393f51bdc3a8857a9517a3b37b76cbbcf010498176af (patch) | |
tree | 389d487d38801518a8f5547a13f0652b8b395081e7b1d4acd788ca819c194906 /layouts | |
parent | d5ef610113470c598bc83100b3d345894788fbffbb3974e6fe225857528147cb (diff) | |
download | hugo-theme-journal-d2b1fbae50be9597c17d393f51bdc3a8857a9517a3b37b76cbbcf010498176af.tar.gz hugo-theme-journal-d2b1fbae50be9597c17d393f51bdc3a8857a9517a3b37b76cbbcf010498176af.zip |
Replace findRE with findRESubmatch where possible
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/_default/single.gmi | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index 13ef9b4..ee837e3 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -9,13 +9,13 @@ # {{ .Name | safeHTML }} {{ $content := .RawContent }} {{- $scratch := newScratch }} -{{- $chunks := findRE `(?sm)(?:(.*?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.*$)` $content }} +{{- $chunks := findRESubmatch `(?sm)(?:(.*?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.*$)` $content }} {{- $ref_index := 0 }} {{- range $chunks }} - {{- $before_pre := replaceRE `(?sm)(?:(.*?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.*$)` "$1" . 1 }} - {{- $pre := replaceRE `(?sm)(?:(.*?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.*$)` "$2" . 1 }} - {{- $after_pre := replaceRE `(?sm)(?:(.*?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.*$)` "$3" . 1 }} + {{- $before_pre := index . 1 }} + {{- $pre := index . 2 }} + {{- $after_pre := index . 3 }} {{- $rendered_text := print $before_pre $after_pre }} @@ -24,8 +24,8 @@ {{- $scratch.Add "refs" $chunk_refs }} {{- range $chunk_refs }} {{- $ref_index = add $ref_index 1 }} - {{- $ref_text := replaceRE `!?\[(.+?)\]\((.+?)(?:\s+".*?")?\)` "$1" . 1 }} - {{- $rendered_text = replace $rendered_text . (print $ref_text "[" $ref_index "]") 1 }} + {{- $ref_text := index . 1 }} + {{- $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") }} @@ -53,8 +53,8 @@ ## Links {{- range $refs }} {{- $ref_index = add $ref_index 1 }} - {{- $ref_text := replaceRE `!?\[(.+?)\]\((.+?)(?:\s+".*?")?\)` "$1" . 1 }} - {{- $ref_link := replaceRE `!?\[(.+?)\]\((.+?)(?:\s+".*?")?\)` "$2" . 1 }} + {{- $ref_text := index . 1 }} + {{- $ref_link := index . 2 }} {{ print "=> " $ref_link (emojify " :link: ") $ref_index ": " $ref_text | safeHTML }} {{- end }} {{- end }} |