aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/_default/_markup/render-codeblock.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-11-21 11:23:56 -0500
committertdro <tdro@noreply.example.com>2022-11-21 11:23:56 -0500
commit8113e9c39376d1e9fb1c239a678a7502272e8fda (patch)
treefc1e9263021d886db60a1b22d3cfee3b7bfa410d /themes/default/layouts/_default/_markup/render-codeblock.html
parent4a82e6046ab0e8cf65a089a7b1e85c6ef918666c (diff)
downloadcanory-8113e9c39376d1e9fb1c239a678a7502272e8fda.tar.gz
canory-8113e9c39376d1e9fb1c239a678a7502272e8fda.tar.bz2
canory-8113e9c39376d1e9fb1c239a678a7502272e8fda.zip
themes/default/layouts: Use hashing algorithm consistently
Avoid using shuffle in short codes by appending .Ordinal value
Diffstat (limited to 'themes/default/layouts/_default/_markup/render-codeblock.html')
-rw-r--r--themes/default/layouts/_default/_markup/render-codeblock.html5
1 files changed, 3 insertions, 2 deletions
diff --git a/themes/default/layouts/_default/_markup/render-codeblock.html b/themes/default/layouts/_default/_markup/render-codeblock.html
index 22d47e4..d629a85 100644
--- a/themes/default/layouts/_default/_markup/render-codeblock.html
+++ b/themes/default/layouts/_default/_markup/render-codeblock.html
@@ -1,7 +1,8 @@
{{- $caption := .Attributes.caption -}}
{{- $type := .Type | default "text" -}}
{{- $options := .Attributes.options | default "default=1" -}}
-{{- $id := print "code-block-" (truncate 7 "" (md5 .Inner)) -}}
+{{- $hash := print (truncate 8 "" (sha256 .Inner)) .Ordinal -}}
+{{- $id := print "code-block-" $hash -}}
<code-block id="{{ $id }}" {{ if in (lower $options) "linenos" }}data-lines{{ end }}>
<header>
@@ -13,7 +14,7 @@
<span>Copy</span>
</button>
</header>
- {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" (truncate 7 "" (md5 .Inner))) }}
+ {{ highlight .Inner $type (print $options ",lineAnchors=" "code-line-" $hash) }}
</code-block>
{{ with $caption }}