summaryrefslogtreecommitdiff
path: root/layouts/_default/single.gmi
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/_default/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 }}