Add calendar shortcode
Some checks failed
/ build (pull_request) Successful in 27s
/ accessibility (pull_request) Failing after 1m38s

This commit is contained in:
Stefan Bethke 2026-10-17 01:51:02 +02:00
commit 6eceb15f18
6 changed files with 140 additions and 0 deletions

View file

@ -0,0 +1,22 @@
{{- /*
One iCalendar (RFC 5545) content line: "NAME:value" plus CRLF, folded so that no line is
longer than 75 bytes (continuation lines start with a space). Params: name, value, text
(true to escape the value as TEXT: backslash, semicolon, comma and newlines).
*/ -}}
{{- $value := .value | default "" -}}
{{- if .text -}}
{{- $value = $value | replaceRE `\\` `\\` | replaceRE `;` `\;` | replaceRE `,` `\,` | replaceRE `\r?\n` `\n` -}}
{{- end -}}
{{- $out := "" -}}
{{- $line := "" -}}
{{- $bytes := 0 -}}
{{- range split (printf "%s:%s" .name $value) "" -}}
{{- if gt (add $bytes (len .)) 75 -}}
{{- $out = printf "%s%s\r\n " $out $line -}}
{{- $line = "" -}}
{{- $bytes = 1 -}}
{{- end -}}
{{- $line = printf "%s%s" $line . -}}
{{- $bytes = add $bytes (len .) -}}
{{- end -}}
{{- return printf "%s%s\r\n" $out $line -}}