From e17004fc6714b7d214aa61f43fa75f1fc9bc0ec00804e0525452cb287a81958a Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Thu, 6 Feb 2025 00:00:00 +0000 Subject: Add non-breaking spaces within entry tag names The spaces in tag names must be non-breaking because tag names split across multiple lines are visually indistinguishable from distinct tags. --- layouts/partials/pageinfo.gmi | 9 ++++++++- layouts/partials/pageinfo.html | 12 +++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/layouts/partials/pageinfo.gmi b/layouts/partials/pageinfo.gmi index adde0c0..9993d93 100644 --- a/layouts/partials/pageinfo.gmi +++ b/layouts/partials/pageinfo.gmi @@ -8,4 +8,11 @@ {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} -{{ emojify ":calendar:" }} {{ $nonBreakingPublishDate }} | {{ emojify ":stopwatch:" }} {{ $nonBreakingReadingTime }}{{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := (.Param (lower (i18n "tags"))) }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} \ No newline at end of file +{{ $nonBreakingTags := slice -}} +{{ range .Param (lower (i18n "tags")) -}} + {{ $nonBreakingTag := replace . " " " " -}} + {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} + {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} +{{ end -}} + +{{ emojify ":calendar:" }} {{ $nonBreakingPublishDate }} | {{ emojify ":stopwatch:" }} {{ $nonBreakingReadingTime }}{{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }}, {{ end }}{{ $val }}{{ end }} \ No newline at end of file diff --git a/layouts/partials/pageinfo.html b/layouts/partials/pageinfo.html index 8917ea7..3ca8fe9 100644 --- a/layouts/partials/pageinfo.html +++ b/layouts/partials/pageinfo.html @@ -10,4 +10,14 @@ {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime " " " " -}} {{ $nonBreakingReadingTime = replace $nonBreakingReadingTime "-" "‑" -}} -{{ emojify ":calendar:" }}  | {{ emojify ":stopwatch:" }} {{ if (.Param (lower (i18n "tags"))) }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := (.Param (lower (i18n "tags"))) }}{{ if $key }} {{ end }}{{ $val }}{{ end }} +{{ $breakingTags := .Param (lower (i18n "tags")) -}} +{{ $nonBreakingTags := slice -}} +{{ range $breakingTags -}} + {{/* user-defined tags are escaped pre-insertion so that HTML entities can be inserted */ -}} + {{ $nonBreakingTag := htmlEscape . -}} + {{ $nonBreakingTag = replace $nonBreakingTag " " " " -}} + {{ $nonBreakingTag = replace $nonBreakingTag "-" "‑" -}} + {{ $nonBreakingTags = $nonBreakingTags | append $nonBreakingTag -}} +{{ end -}} + +{{ emojify ":calendar:" }}  | {{ emojify ":stopwatch:" }} {{ if $nonBreakingTags }} | {{ emojify ":label:" }} {{ end }}{{ range $key, $val := $nonBreakingTags }}{{ if $key }} {{ end }}{{ $val | safeHTML }}{{ end }} -- cgit v1.2.3