aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Johnson <nick@nicholasjohnson.ch>2023-08-25 00:00:00 +0000
committerNicholas Johnson <nick@nicholasjohnson.ch>2023-08-25 00:00:00 +0000
commit4daeb8accf5177ec6cf1278debc3d92e9e3bee22b8f3fdf87828d3b513bdbd42 (patch)
tree7173c20df70049d1f8145eaaa05b92487da662a598b94f4477815e43b51aacf0
parent001e84a04e9a3d11cfa8635df2d4557687f17280a1c4d2ed7eda2d0794ca3d32 (diff)
Fix spacing heading spacing for single.gmi
-rw-r--r--layouts/_default/single.gmi8
1 files changed, 7 insertions, 1 deletions
diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi
index 23ca547..e0361d8 100644
--- a/layouts/_default/single.gmi
+++ b/layouts/_default/single.gmi
@@ -9,9 +9,14 @@
# {{ .Name | safeHTML }}
+
{{ $content := chomp (.RawContent) -}}
{{ $scratch := newScratch -}}
+{{/* if content begins with a heading, add an extra space */ -}}
+{{ if (findRE `(?)^#{1,3}` $content) }}
+{{ end -}}
+
{{/* split text into chunks, with each chunk containing 3 parts: above, within, and below preformatted text */ -}}
{{/* the regex matching below the preformatted text matches exactly once in the entire text */ -}}
{{ $chunks := findRESubmatch `(?sm)(?:(.+?)(^\x60{3}[^\x60].*?^\x60{3}$))|(.+$)` $content -}}
@@ -40,6 +45,7 @@
{{ $rendered_text = replace $rendered_text (index . 0) (print $ref_text "[" $ref_index "]") 1 -}}
{{ end -}}
+
{{ else -}}
{{/* render all links directly */ -}}
@@ -98,4 +104,4 @@
{{ print "=> " $ref_link (emojify " :link: ") $ref_index ": " (cond (ne (len $ref_title) 0) $ref_title $ref_text) | safeHTML -}}
{{ end -}}
{{ end -}}
-{{ end }} \ No newline at end of file
+{{ end }}