From ac7486160b8a322abfa14fbe97cae4a6a1b7be81a7c9f80dfe3d7e43d2e8b429 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Fri, 3 Nov 2023 00:00:00 +0000 Subject: Use superscripted reference numbers for links The implementation is ugly, but I couldn't find another way to accomplish this. --- layouts/_default/single.gmi | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'layouts/_default') diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index 94b7c62..b566ff3 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -41,8 +41,20 @@ {{ $ref_index = add $ref_index 1 -}} {{ $ref_text := index . 1 -}} - {{/*- replace link with reference numbers enclosed in brackets */ -}} - {{ $rendered_text = replace $rendered_text (index . 0) (print $ref_text "[" $ref_index "]") 1 -}} + {{/* create superscript of $ref_index */ -}} + {{ $ref_index := replace $ref_index "0" "⁰" -}} + {{ $ref_index = replace $ref_index "1" "¹" -}} + {{ $ref_index = replace $ref_index "2" "²" -}} + {{ $ref_index = replace $ref_index "3" "³" -}} + {{ $ref_index = replace $ref_index "4" "⁴" -}} + {{ $ref_index = replace $ref_index "5" "⁵" -}} + {{ $ref_index = replace $ref_index "6" "⁶" -}} + {{ $ref_index = replace $ref_index "7" "⁷" -}} + {{ $ref_index = replace $ref_index "8" "⁸" -}} + {{ $ref_index = replace $ref_index "9" "⁹" -}} + + {{/* replace Markdown links with link text and their superscripted reference numbers */ -}} + {{ $rendered_text = replace $rendered_text (index . 0) (print $ref_text $ref_index) 1 -}} {{ end -}} -- cgit v1.2.3