From 4daeb8accf5177ec6cf1278debc3d92e9e3bee22b8f3fdf87828d3b513bdbd42 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Fri, 25 Aug 2023 00:00:00 +0000 Subject: Fix spacing heading spacing for single.gmi --- layouts/_default/single.gmi | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'layouts/_default') 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 }} -- cgit v1.2.3