From 98a9d782730fd714ae7a3300d8cf6791ed0bc341 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 26 Dec 2024 12:33:59 -0800 Subject: [PATCH] Generate source offset in HTML Signed-off-by: Danila Fedorin --- layouts/partials/highlightgroup.html | 3 +++ layouts/shortcodes/codelines.html | 1 + 2 files changed, 4 insertions(+) diff --git a/layouts/partials/highlightgroup.html b/layouts/partials/highlightgroup.html index 34387e6..f6054c0 100644 --- a/layouts/partials/highlightgroup.html +++ b/layouts/partials/highlightgroup.html @@ -6,4 +6,7 @@ {{- if eq (lower .language) "agda" -}} {{- $scratch.Add "highlightGroupAttrs" " data-agda-block" -}} {{- end -}} +{{- with .offset -}} +{{- $scratch.Add "highlightGroupAttrs" (printf " data-source-offset=\"%v\"" .) -}} +{{- end -}} {{ partial "group.html" (dict "url" .url "path" .path "comment" .comment "content" (highlight .code .language .opts) "attrs" ($scratch.Get "highlightGroupAttrs")) }} diff --git a/layouts/shortcodes/codelines.html b/layouts/shortcodes/codelines.html index 71266ab..0993e55 100644 --- a/layouts/shortcodes/codelines.html +++ b/layouts/shortcodes/codelines.html @@ -51,6 +51,7 @@ "firstLine" (int (.Get 2)) "lastLine" (int (.Get 3)) "language" (.Get 0) + "offset" ($scratch.Get "prefixLength") "opts" (printf "linenos=table,linenostart=%d%s" (.Get 2) ($scratch.Get "opts")) -}} {{- partial "highlightgroup.html" $groupconfig -}}