{{- /* Code block wrapper hook for highlight output. - Applies wrapper UI features based on codeblock config. - Supports classic/modern modes, copy button, expand button, and line-number states. @param {Object} .Attributes - Code block attributes @param {Object} .Options - Code fence options @param {String} .Inner - Raw code content @param {Object} .Page - Current page context @param {String} .Type - Language/type for current block */ -}} {{- $config := .Attributes | merge (dict "Page" .Page "Key" "codeblock" | partial "function/param.html") -}} {{- /* Deprecated camelCase attribute support: Hugo lowercases Markdown attributes */ -}} {{- if isset .Attributes "wrapperclass" | and (not (isset .Attributes "wrapper_class")) -}} {{- warnidf "v1-deprecated-codeblock-attr" "The attribute `wrapperClass` is deprecated since v1.0.0, use `wrapper_class` instead. See %s" .Position -}} {{- end -}} {{- if isset .Attributes "maxshownlines" | and (not (isset .Attributes "max_shown_lines")) -}} {{- warnidf "v1-deprecated-codeblock-attr" "The attribute `maxShownLines` is deprecated since v1.0.0, use `max_shown_lines` instead. See %s" .Position -}} {{- end -}} {{- if isset .Attributes "linenostoggler" | and (not (isset .Attributes "line_nos_toggler")) -}} {{- warnidf "v1-deprecated-codeblock-attr" "The attribute `lineNosToggler` is deprecated since v1.0.0, use `line_nos_toggler` instead. See %s" .Position -}} {{- end -}} {{- if isset .Attributes "linewraptoggler" | and (not (isset .Attributes "line_wrap_toggler")) -}} {{- warnidf "v1-deprecated-codeblock-attr" "The attribute `lineWrapToggler` is deprecated since v1.0.0, use `line_wrap_toggler` instead. See %s" .Position -}} {{- end -}} {{- $result := transform.HighlightCodeBlock . -}} {{- $wrapper := $result.Wrapped -}} {{- /* If wrapper is enabled, add code wrapper and more features */ -}} {{- if $config.wrapper -}} {{- $mode := $config.mode | default "classic" -}} {{- $lines := cond .Inner (len (split .Inner "\n")) 0 -}} {{- $maxShownLines := $config.max_shown_lines | default .Attributes.maxshownlines -}} {{- $lineNoStart := cond (ne .Options.linenostart nil) .Options.linenostart 1 -}} {{- $lineNosDigit := strings.RuneCount (sub (add $lines $lineNoStart) 1) -}} {{- $class := "highlight" -}} {{- with $config.class -}}{{ $class = add $class " " . }}{{- end -}} {{- $targetClass := add "code-block " $class -}} {{- with ($config.wrapper_class | default .Attributes.wrapperclass) -}}{{ $targetClass = add $targetClass " " . }}{{- end -}} {{- /* Add code wrapper around the table or pre */ -}} {{- $REin := cond (strings.Contains $wrapper `