diff options
author | tdro <tdro@noreply.example.com> | 2023-10-07 20:19:06 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-10-07 20:19:06 -0400 |
commit | 5730919857b1f6a31784c95a305bf924436678c2 (patch) | |
tree | f2124df2d0753be4f1f915d67346289fb3fcadec /themes/default/layouts/shortcodes | |
parent | c83c49b0e18f0593a62a8a7754d1ff49ac097289 (diff) | |
download | canory-5730919857b1f6a31784c95a305bf924436678c2.tar.gz canory-5730919857b1f6a31784c95a305bf924436678c2.tar.bz2 canory-5730919857b1f6a31784c95a305bf924436678c2.zip |
themes/default/layouts/shortcodes/mark: Support id
Diffstat (limited to 'themes/default/layouts/shortcodes')
-rw-r--r-- | themes/default/layouts/shortcodes/mark.html | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/themes/default/layouts/shortcodes/mark.html b/themes/default/layouts/shortcodes/mark.html index 122a521..1b9ef3d 100644 --- a/themes/default/layouts/shortcodes/mark.html +++ b/themes/default/layouts/shortcodes/mark.html @@ -1,9 +1,15 @@ {{- $text := default "mark" (.Get "text" | default (.Get 0)) -}} {{- $title := default "highlighted text" (.Get "title" | default (.Get 1)) -}} +{{- $id := default "" (.Get "id" | default (.Get 2)) -}} {{- if gt (len .Inner) 1 -}} - {{- $text = .Inner -}} + {{- $text = trim .Inner "\n" -}} {{- end -}} -<mark title="{{- $title -}}">{{- $text -}}</mark> +{{- if $id -}} + {{- $id = print "mark:" (truncate 30 "" $text | anchorize | replaceRE `\d` "") -}} + {{- $id = printf `id=%q` $id -}} +{{- end -}} + +<mark {{ $id | safeHTMLAttr }} title="{{- $title -}}"><span>{{- $text | markdownify -}}</span></mark> {{- /* This comment removes trailing newlines and white spaces. */ -}} |